bug in the code of argp-standalone-1.3/strndup.c
Brought to you by:
moxie
Originally created by: avne...@gmail.com
The following piece of code contains wrong check for error condition:
----
r = malloc(size);
if (size)
{
memcpy(r, s, size-1);
r[size-1] = '\0';
}
return r;
----
The author probably intended to check "if (r)"
Also, notice, that the semantic of your code has "off by one" bug when relating to the semantic of the original GNU function. See man strndup - they will allocate size+1 bytes and not just size bytes as you do.
HTH,
Avner
View and moderate all "tickets Discussion" comments posted by this user
Mark all as spam, and block user from posting to "Tickets"
Originally posted by: avne...@gmail.com
FYI - you can take the author fix for these bugs from here: https://git.lysator.liu.se/lsh/lsh/commit/8a0cc32f349aac3c8c3084fdb380c9d1a2338d91
Thanks!
Chris
Diff: