Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8014c61

Browse files
committed
Don't call fwrite() with len == 0 when writing out relcache init file.
Noticed via -fsanitize=undefined. Backpatch to all branches, for the same reasons as 46ab07f. Discussion: https://postgr.es/m/20220323173537.ll7klrglnp4gn2um@alap3.anarazel.de Backpatch: 10-
1 parent 7c163aa commit 8014c61

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/utils/cache/relcache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6365,7 +6365,7 @@ write_item(const void *data, Size len, FILE *fp)
63656365
{
63666366
if (fwrite(&len, 1, sizeof(len), fp) != sizeof(len))
63676367
elog(FATAL, "could not write init file");
6368-
if (fwrite(data, 1, len, fp) != len)
6368+
if (len > 0 && fwrite(data, 1, len, fp) != len)
63696369
elog(FATAL, "could not write init file");
63706370
}
63716371

0 commit comments

Comments
 (0)