[Github-comments] [geany/geany] editor: fix incorrect variable reference (#1561)
Matthew Brush
notifications at xxxxx
Thu Jul 27 00:10:06 UTC 2017
codebrainz commented on this pull request.
> @@ -2475,6 +2474,7 @@ void editor_insert_text_block(GeanyEditor *editor, const gchar *text, gint inser
/* count indent size up to insert_pos instead of asking sci
* because there may be spaces after it */
gchar *tmp = sci_get_line(sci, line_start);
+ gint idx;
idx = insert_pos - sci_get_position_from_line(sci, line_start);
I know it's not changed by this PR, but should the assertion above (L2465) be `g_return_if_fail(insert_pos > 0);` instead (or checking that `idx` is within the `tmp` buffer afterwards)? Also I wonder whether the result of `sci_get_position_from_line()` or `line_start` should be validated as it can return -1 or the number of lines in the file if `line_start` is greater or equal to the number of lines in the document. I'm always worried when I see arbitrary unchecked integers indexing directly into memory buffer :)
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/1561#pullrequestreview-52530352
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20170727/8975df20/attachment.html>
More information about the Github-comments
mailing list