From 3ef083767eaf975399243246605fddc40cc097f9 Mon Sep 17 00:00:00 2001 From: Aaron Puchert Date: Thu, 19 Oct 2017 14:04:35 +0200 Subject: Prevent crashes and leaks on allocation failure (#606) * Prevent crashes and leaks on allocation failure Memory allocation can fail. We need to gracefully handle this case and prevent dereferencing null pointers. * Make NULL checks consistent within a file * Properly report allocation errors * Improve cleanup in pj_gc_reader.c * Implement pj_strdup and use instead of strdup The function strdup is not part of ANSI C 89, but a POSIX extension. Therefore we can not rely on it being available on all platforms. --- test/fuzzers/standard_fuzzer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/fuzzers/standard_fuzzer.cpp b/test/fuzzers/standard_fuzzer.cpp index a39a2dbf..73c7827a 100644 --- a/test/fuzzers/standard_fuzzer.cpp +++ b/test/fuzzers/standard_fuzzer.cpp @@ -47,7 +47,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t len); int LLVMFuzzerInitialize(int* /*argc*/, char*** argv) { const char* argv0 = (*argv)[0]; - char* path = strdup(argv0); + char* path = pj_strdup(argv0); char* lastslash = strrchr(path, '/'); if( lastslash ) { -- cgit v1.2.3