diff --git a/libc/fuzzing/string/strcmp_fuzz.cpp b/libc/fuzzing/string/strcmp_fuzz.cpp --- a/libc/fuzzing/string/strcmp_fuzz.cpp +++ b/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