[Github-comments] [geany/geany-plugins] [geanylua] geany.scintilla() does not work with SCI_SETLEXER (#646)

Matthew Brush notifications at xxxxx
Tue Nov 21 10:32:47 UTC 2017


> Thats why its a stupid warning (or at least stupid to enable by default) because many system interfaces use int as a counter (like argc) and everybody knows they are never negative

To be fair, it's not the _actual_ `argc`, it's a random value popped off the Lua stack, it could be anything and the code only guards against value `0`, not `< 0`.

Also, unrelated, that line looks wrong because of the order of operations and missing parenthesis, I believe it will allocate room for the needed pointers plus one byte. Presumably it's meant to be `sizeof(gchar*) * (argc+1)` to allocate storage for the number of pointers plus one extra pointer for the sentinel `NULL` as is customary with `argv`/`GStrv`.

To fix the warning and bug, it could probably be changed to:

```c
argv = g_malloc0_n(argc+1, sizeof(gchar*));
```


-- 
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-plugins/issues/646#issuecomment-345984959
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20171121/e4eac455/attachment.html>


More information about the Github-comments mailing list