From 59b80a08094f35a9f38b786b561103e1b39596dc Mon Sep 17 00:00:00 2001 From: Milan Nikolic Date: Fri, 2 Sep 2022 15:04:19 +0200 Subject: [PATCH] Update C sources --- unarrc/external/unarr/_7z/_7z.c | 1 + unarrc/external/unarr/common/unarr-imp.h | 5 ++++- unarrc/external/unarr/rar/rarvm.c | 11 ++++++----- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/unarrc/external/unarr/_7z/_7z.c b/unarrc/external/unarr/_7z/_7z.c index 0e163b2..4c5a3b9 100644 --- a/unarrc/external/unarr/_7z/_7z.c +++ b/unarrc/external/unarr/_7z/_7z.c @@ -45,6 +45,7 @@ static void _7z_close(ar_archive *ar) free(_7z->entry_name); SzArEx_Free(&_7z->data, &gSzAlloc); IAlloc_Free(&gSzAlloc, _7z->uncomp.buffer); + IAlloc_Free(&gSzAlloc, _7z->look_stream.buf); } static const char *_7z_get_name(ar_archive *ar, bool raw); diff --git a/unarrc/external/unarr/common/unarr-imp.h b/unarrc/external/unarr/common/unarr-imp.h index aec2e2c..d45d101 100644 --- a/unarrc/external/unarr/common/unarr-imp.h +++ b/unarrc/external/unarr/common/unarr-imp.h @@ -43,8 +43,11 @@ struct ar_stream_s { ar_stream *ar_open_stream(void *data, ar_stream_close_fn close, ar_stream_read_fn read, ar_stream_seek_fn seek, ar_stream_tell_fn tell); /***** unarr *****/ - +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION #define warn(...) ar_log("!", __FILE__, __LINE__, __VA_ARGS__) +#else +#define warn(...) ((void)0) +#endif #ifndef NDEBUG #define log(...) ar_log("-", __FILE__, __LINE__, __VA_ARGS__) #else diff --git a/unarrc/external/unarr/rar/rarvm.c b/unarrc/external/unarr/rar/rarvm.c index 8167c67..47e32ab 100644 --- a/unarrc/external/unarr/rar/rarvm.c +++ b/unarrc/external/unarr/rar/rarvm.c @@ -49,13 +49,14 @@ bool RARProgramAddInstr(RARProgram *prog, uint8_t instruction, bool bytemode) if (prog->length + 1 >= prog->capacity) { /* in my small file sample, 16 is the value needed most often */ uint32_t newCapacity = prog->capacity ? prog->capacity * 4 : 32; - if (!prog->opcodes) - return false; RAROpcode *newCodes = calloc(newCapacity, sizeof(*prog->opcodes)); - if (!newCodes) + if (!newCodes) { return false; - memcpy(newCodes, prog->opcodes, prog->capacity * sizeof(*prog->opcodes)); - free(prog->opcodes); + } + if (prog->opcodes) { + memcpy(newCodes, prog->opcodes, prog->capacity * sizeof(*prog->opcodes)); + free(prog->opcodes); + } prog->opcodes = newCodes; prog->capacity = newCapacity; }