You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* tal_strndup - duplicate a limited amount of a string.
* @ctx: NULL, or tal allocated object to be parent.
* @p: the string to copy (can be take()).
* @n: the maximum length to copy.
*
* Always gives a nul-terminated string, with strlen() <= @n.
* The returned string will have tal_count() == strlen() + 1.
*/
However, when tal_strndup(ctx, NULL, n) is called with n being any non-zero integer, the returned string will have tal_count() equal to n + 1 (i.e., at least 2), but strlen() will be equal to zero. 2 != 0 + 1.
The contract for
tal_strndup
says:ccan/ccan/tal/str/str.h
Lines 22 to 30 in cd56b18
However, when
tal_strndup(ctx, NULL, n)
is called withn
being any non-zero integer, the returned string will havetal_count()
equal ton + 1
(i.e., at least 2), butstrlen()
will be equal to zero.2 != 0 + 1
.ccan/ccan/tal/str/str.c
Lines 27 to 30 in cd56b18
It seems like this^ really should say
len = 0;
in theelse
branch.The text was updated successfully, but these errors were encountered: