Skip to content

Commit

Permalink
thdat02: don't try to free() a mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
DankRank committed Dec 7, 2024
1 parent b4023a7 commit eae5642
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion thtk/thdat02.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,13 @@ th02_read(
ret = thtk_io_write(output, data, entry->zsize, error);
thtk_io_unmap(thdat->stream, data);
} else {
thtk_io_t* data_stream = thtk_io_open_memory(data, entry->zsize, error);
/* FIXME: ouch, an unnecessary copy, due to thtk_io_open_memory taking ownership */
void *data2 = malloc(entry->zsize);
if (!data2)
return -1;
memcpy(data2, data, entry->zsize);

thtk_io_t* data_stream = thtk_io_open_memory(data2, entry->zsize, error);
if (!data_stream)
return -1;
ret = thtk_unrle(data_stream, entry->zsize, output, error);
Expand Down

0 comments on commit eae5642

Please sign in to comment.