Skip to content

Commit

Permalink
ANM: correctness fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
32th-System committed Aug 26, 2023
1 parent f5e52d0 commit 50e2b73
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions thcrap_tsa/src/anm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1233,8 +1233,9 @@ int patch_anm(void *file_inout, size_t size_out, size_t size_in, const char *fn,
png_image_ex png = {};
png_image_ex bounds = {};

auto* anm_entry_in = (uint8_t*)malloc(size_in);
memmove(anm_entry_in, file_inout, size_in);
auto* file_in = (uint8_t*)malloc(size_in);
auto* anm_entry_in = file_in;
memcpy(anm_entry_in, file_inout, size_in);
memset(file_inout, 0, size_out);

auto *anm_entry_out = (uint8_t *)file_inout;
Expand Down Expand Up @@ -1301,7 +1302,7 @@ int patch_anm(void *file_inout, size_t size_out, size_t size_in, const char *fn,
}
png_image_clear(bounds);
png_image_clear(png);
free(anm_entry_in);
free(file_in);

log_debugf("-------------\n");
return 1;
Expand Down Expand Up @@ -1343,8 +1344,8 @@ size_t anm_get_size(const char* fn, json_t* patch, size_t patch_size) {
return 0;
}

auto* file_load = (file_load_t*)func_get(file_load_func_name);
auto* _ingame_free = (ingame_free_t*)func_get(free_func_name);
auto* file_load = (file_load_t*)json_object_get_eval_addr_default(runcfg, "file_load_func", NULL, JEVAL_DEFAULT);
auto* _ingame_free = (ingame_free_t*)json_object_get_eval_addr_default(runcfg, "free_func", NULL, JEVAL_DEFAULT);

if (!file_load || !_ingame_free) {
return 0;
Expand Down

0 comments on commit 50e2b73

Please # to comment.