[PATCH] avoid using strnlen result for late calls to strlen (PR 82604)

Martin Sebor msebor@gmail.com
Mon Jun 18 19:15:00 GMT 2018


While looking into opportunities to detect strnlen/strlen coding
mistakes (pr86199) I noticed a bug in the strnlen implementation
I committed earlier today that lets a strnlen() result be saved
and used in subsequent calls to strlen() with the same argument.
The attached patch changes the handle_builtin_strlen() function
to discard the strnlen() result unless its bound is greater than
the length of the string.

Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gcc-86204.diff
Type: text/x-patch
Size: 4891 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180618/70f3da0a/attachment.bin>


More information about the Gcc-patches mailing list