Skip to content

Commit

Permalink
Update C sources
Browse files Browse the repository at this point in the history
  • Loading branch information
gen2brain committed Sep 2, 2022
1 parent c496c96 commit 59b80a0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions unarrc/external/unarr/_7z/_7z.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 4 additions & 1 deletion unarrc/external/unarr/common/unarr-imp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions unarrc/external/unarr/rar/rarvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 59b80a0

Please sign in to comment.