# HG changeset patch # User Matti Hamalainen # Date 1605094503 -7200 # Node ID d51c277bea6beaefb9751100acffa743d3a66014 # Parent ffd97ca9dfce71b5c594d9e3e48e282f949e2755 Set th_ioctx::memAlloc to zero in th_mem_fclose() if memory is freed. This fixes the issue if file is reopened and th_mem_realloc() fails to notice that we have no allocated memory. diff -r ffd97ca9dfce -r d51c277bea6b th_ioctx_mem.c --- a/th_ioctx_mem.c Wed Nov 11 13:23:24 2020 +0200 +++ b/th_ioctx_mem.c Wed Nov 11 13:35:03 2020 +0200 @@ -46,7 +46,11 @@ static void th_mem_fclose(th_ioctx *ctx) { if (ctx->memFree) + { th_free_r(&ctx->memData); + ctx->memAlloc = 0; + ctx->memSize = 0; + } }