mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
Merge remote-tracking branch 'public/string_coverage'
This commit is contained in:
commit
622a057e7e
@ -101,7 +101,7 @@ tor_vasprintf(char **strp, const char *fmt, va_list args)
|
|||||||
/* If the platform gives us one, use it. */
|
/* If the platform gives us one, use it. */
|
||||||
int r = vasprintf(&strp_tmp, fmt, args);
|
int r = vasprintf(&strp_tmp, fmt, args);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
*strp = NULL;
|
*strp = NULL; // LCOV_EXCL_LINE -- no cross-platform way to force this
|
||||||
else
|
else
|
||||||
*strp = strp_tmp;
|
*strp = strp_tmp;
|
||||||
return r;
|
return r;
|
||||||
|
@ -3163,6 +3163,21 @@ test_util_sscanf(void *arg)
|
|||||||
test_feq(d3, -900123123.2000787);
|
test_feq(d3, -900123123.2000787);
|
||||||
test_feq(d4, 3.2);
|
test_feq(d4, 3.2);
|
||||||
|
|
||||||
|
/* missing float */
|
||||||
|
r = tor_sscanf("3 ", "%d %lf", &int1, &d1);
|
||||||
|
tt_int_op(r, OP_EQ, 1);
|
||||||
|
tt_int_op(int1, OP_EQ, 3);
|
||||||
|
|
||||||
|
/* not a float */
|
||||||
|
r = tor_sscanf("999 notafloat", "%d %lf", &int1, &d1);
|
||||||
|
tt_int_op(r, OP_EQ, 1);
|
||||||
|
tt_int_op(int1, OP_EQ, 999);
|
||||||
|
|
||||||
|
/* %s but no buffer. */
|
||||||
|
char *nullbuf = NULL;
|
||||||
|
r = tor_sscanf("hello", "%3s", nullbuf);
|
||||||
|
tt_int_op(r, OP_EQ, 0);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
tor_free(huge);
|
tor_free(huge);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user