From: Karina Litskevich Date: Mon, 28 Aug 2023 11:53:12 +0000 (+0300) Subject: Bugfix: make sure fclose is called with a legal argument X-Git-Tag: REL_16_0~13 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=25f1954a592e323d6cbc126efb8b9036eb4f343f;p=pg_filedump.git Bugfix: make sure fclose is called with a legal argument fclose(NULL) is an UB --- diff --git a/decode.c b/decode.c index 565ef58..bf28189 100644 --- a/decode.c +++ b/decode.c @@ -1351,8 +1351,7 @@ ReadStringFromToast(const char *buffer, toast_relation_filename); result = -1; } - - if (result == 0) + else { unsigned int toast_relation_block_size = GetBlockSize(toast_rel_fp); fseek(toast_rel_fp, 0, SEEK_SET); @@ -1382,9 +1381,9 @@ ReadStringFromToast(const char *buffer, } free(toast_data); + fclose(toast_rel_fp); } - fclose(toast_rel_fp); free(toast_relation_path); } /* If tag is indirect or expanded, it was stored in memory. */