[Github-comments] [geany/geany-plugins] Splitting a snowman in half crashes Geany with Spell Check (inserting a space before Unicode VARIATION SELECTOR-16) (#1041)

elextr notifications at xxxxx
Mon Dec 7 12:28:34 UTC 2020


@b4n, by default the C++ vector index is unchecked, but no index is legal on a zero length vector, its UB, as the spec says about operator[] `Accessing a nonexistent element through this operator is undefined behavior.`.

The assertions flag makes it checked, as the message you posted above says `Assertion '__builtin_expect(__n < this->size(), true)' failed`, and if size() is 0 its impossible for __n to be < 0.

The reason its UB is that the vector would have to have at least one member to have memory allocated be able to access vector[0], but if size() is zero it need not have any memory allocated, remember std::vector is dynamic.

The reason nothing fails without the assertion is that Scintilla uses resize() as one of my links above points out, which does not de-allocate the vector memory, and its extremely likely that the vector has some memory left from previous operations, so its internal pointer is not `nullptr`.

@hroncok yeah, I'm sure lots of other programs have bugs found when the flag makes vector indexing checked :grin:

-- 
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/1041#issuecomment-739888025
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20201207/b2ec6de8/attachment.htm>


More information about the Github-comments mailing list