diff options
author | Christian Hergert <chergert@redhat.com> | 2023-04-26 16:42:40 -0700 |
---|---|---|
committer | Christian Hergert <chergert@redhat.com> | 2023-04-27 09:17:00 -0700 |
commit | f9bdff77ef4ff6abbc999ad6cb03bb2cf7e4f5bc (patch) | |
tree | 5c605a683639453b4287a28af76274114a66e628 | |
parent | eb639cfb89e4a3575fcb9102c40cf751b4381447 (diff) | |
download | gtksourceview-5-6.tar.gz |
bufferoutputstream: be defensive about dereferencing nul bytegtksourceview-5-6
If we don't own the buffer, then we don't have a guarantee that the buffer
is one byte bigger than any count/length we've received. Mke sure to only
dereference that byte when we do.
Related #309
-rw-r--r-- | gtksourceview/gtksourcebufferoutputstream.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gtksourceview/gtksourcebufferoutputstream.c b/gtksourceview/gtksourcebufferoutputstream.c index 2816cb6d..566e96b9 100644 --- a/gtksourceview/gtksourcebufferoutputstream.c +++ b/gtksourceview/gtksourcebufferoutputstream.c @@ -705,7 +705,8 @@ validate_and_insert (GtkSourceBufferOutputStream *stream, apply_error_tag (stream); - if ((nvalid != len || !owned) && buffer[nvalid] != '\0') + if (!owned || + (nvalid != len && buffer[nvalid] != '\0')) { /* make sure the buffer is always properly null * terminated. This is needed, at least for now, |