diff options
author | Patrick Monnerat <patrick@monnerat.net> | 2020-01-28 02:44:29 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-03-08 17:30:55 +0100 |
commit | a75f12768dee349e5671022c2bbea5428e6cca19 (patch) | |
tree | 7ae6975736b2cb5d86119f89b6ab5cd7058ec0e0 /tests | |
parent | 1369b8ad31d5fff44af1a0f2b5fa8b24b4c24b09 (diff) |
test 1560: avoid valgrind false positives
When using maximum code optimization level (-O3), valgrind wrongly
detects uses of uninitialized values in strcmp().
Preset buffers with all zeroes to avoid that.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/libtest/lib1560.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/libtest/lib1560.c b/tests/libtest/lib1560.c index 6228a137b..fbe642c20 100644 --- a/tests/libtest/lib1560.c +++ b/tests/libtest/lib1560.c @@ -60,7 +60,7 @@ static int checkparts(CURLU *u, const char *in, const char *wanted, {CURLUPART_FRAGMENT, "fragment"}, {0, NULL} }; - buf[0] = 0; + memset(buf, 0, sizeof(buf)); for(i = 0; parts[i].name; i++) { char *p = NULL; @@ -645,6 +645,9 @@ static CURLUcode updateurl(CURLU *u, const char *cmd, unsigned int setflags) char buf[80]; char part[80]; char value[80]; + + memset(part, 0, sizeof(part)); /* Avoid valgrind false positive. */ + memset(value, 0, sizeof(value)); /* Avoid valgrind false positive. */ memcpy(buf, p, n); buf[n] = 0; if(2 == sscanf(buf, "%79[^=]=%79[^,]", part, value)) { |