diff --git a/fuzz/build.sh b/fuzz/build.sh index d87cbdff..a856c5e3 100644 --- a/fuzz/build.sh +++ b/fuzz/build.sh @@ -9,6 +9,10 @@ if [ $# -ge 1 ]; then FUZZER_SUFFIX="`echo $1 | sed 's/\./_/g'`" fi +if [ "$SANITIZER" = "memory" ]; then + export CFLAGS="$CFLAGS -DZERO_BUFFERS=1" +fi + cmake . -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_STATIC=1 -DENABLE_SHARED=0 \ -DCMAKE_C_FLAGS_RELWITHDEBINFO="-g -DNDEBUG" \ -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-g -DNDEBUG" -DCMAKE_INSTALL_PREFIX=$WORK \ diff --git a/fuzz/compress.cc b/fuzz/compress.cc index daad0471..995840b2 100644 --- a/fuzz/compress.cc +++ b/fuzz/compress.cc @@ -1,5 +1,5 @@ /* - * Copyright (C)2021, 2023 D. R. Commander. All Rights Reserved. + * Copyright (C)2021, 2023-2024 D. R. Commander. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -89,7 +89,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) maxBufSize = tj3JPEGBufSize(width, height, tests[ti].subsamp); if (tj3Get(handle, TJPARAM_NOREALLOC)) { - if ((dstBuf = (unsigned char *)malloc(maxBufSize)) == NULL) + if ((dstBuf = (unsigned char *)tj3Alloc(maxBufSize)) == NULL) goto bailout; } else dstBuf = NULL; diff --git a/fuzz/compress12.cc b/fuzz/compress12.cc index 12cb7565..63131c8f 100644 --- a/fuzz/compress12.cc +++ b/fuzz/compress12.cc @@ -1,5 +1,5 @@ /* - * Copyright (C)2021, 2023 D. R. Commander. All Rights Reserved. + * Copyright (C)2021, 2023-2024 D. R. Commander. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -89,7 +89,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) maxBufSize = tj3JPEGBufSize(width, height, tests[ti].subsamp); if (tj3Get(handle, TJPARAM_NOREALLOC)) { - if ((dstBuf = (unsigned char *)malloc(maxBufSize)) == NULL) + if ((dstBuf = (unsigned char *)tj3Alloc(maxBufSize)) == NULL) goto bailout; } else dstBuf = NULL; diff --git a/fuzz/transform.cc b/fuzz/transform.cc index 84a8ccec..f3b5b265 100644 --- a/fuzz/transform.cc +++ b/fuzz/transform.cc @@ -1,5 +1,5 @@ /* - * Copyright (C)2021-2023 D. R. Commander. All Rights Reserved. + * Copyright (C)2021-2024 D. R. Commander. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -70,7 +70,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) transforms[0].op = TJXOP_NONE; transforms[0].options = TJXOPT_PROGRESSIVE | TJXOPT_COPYNONE; dstBufs[0] = - (unsigned char *)malloc(tj3JPEGBufSize(width, height, jpegSubsamp)); + (unsigned char *)tj3Alloc(tj3JPEGBufSize(width, height, jpegSubsamp)); if (!dstBufs[0]) goto bailout;