Skip to content

Commit 89a94c2

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 e52e9bd commit 89a94c2

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
@@ -6485,7 +6485,7 @@ write_item(const void *data, Size len, FILE *fp)
64856485
{
64866486
if (fwrite(&len, 1, sizeof(len), fp) != sizeof(len))
64876487
elog(FATAL, "could not write init file");
6488-
if (fwrite(data, 1, len, fp) != len)
6488+
if (len > 0 && fwrite(data, 1, len, fp) != len)
64896489
elog(FATAL, "could not write init file");
64906490
}
64916491

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy