[libc-commits] [PATCH] D82427: [libc] Fix strcmp fuzz test to use one input.
Chris Gyurgyik via Phabricator via libc-commits
libc-commits at lists.llvm.org
Wed Jun 24 05:54:47 PDT 2020
cgyurgyik updated this revision to Diff 272999.
cgyurgyik added a comment.
Add corresponding deletes.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D82427/new/
https://reviews.llvm.org/D82427
Files:
libc/fuzzing/string/strcmp_fuzz.cpp
Index: libc/fuzzing/string/strcmp_fuzz.cpp
===================================================================
--- libc/fuzzing/string/strcmp_fuzz.cpp
+++ libc/fuzzing/string/strcmp_fuzz.cpp
@@ -15,7 +15,7 @@
// The general structure is to take the value of the first byte, set size1 to
// that value, and add the null terminator. size2 will then contain the rest of
-// the bytes in data. For example: Inputs: data: [2, 6, 4, 8, 0], size: 5 Split:
+// the bytes in data. For example, with inputs ([2, 6, 4, 8, 0], 5):
// size1: data[0] = 2
// data1: [2, 6] + '\0' = [2, 6, '\0']
// size2: size - size1 = 3
@@ -38,12 +38,16 @@
// Copy the data into new containers.
// Add one for null terminator.
uint8_t *data1 = new uint8_t[size1 + 1];
+ if (!data1)
+ __builtin_trap();
size_t i;
for (i = 0; i < size1; ++i)
data1[i] = data[i];
data1[size1] = '\0'; // Add null terminator to data1.
uint8_t *data2 = new uint8_t[size2];
+ if (!data2)
+ __builtin_trap();
for (size_t j = 0; j < size2; ++i, ++j)
data2[j] = data[i];
// Verify the second string is null-terminated.
@@ -80,5 +84,8 @@
if (expected_result != actual_result)
__builtin_trap();
+ delete[] data1;
+ delete[] data2;
+
return 0;
-}
+}
\ No newline at end of file
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82427.272999.patch
Type: text/x-patch
Size: 1312 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20200624/0675f683/attachment.bin>
More information about the libc-commits
mailing list