mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-06 11:39:19 +02:00
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 46ab07ffda
.
Discussion: https://postgr.es/m/20220323173537.ll7klrglnp4gn2um@alap3.anarazel.de
Backpatch: 10-
This commit is contained in:
parent
6a767bc2e7
commit
c5b60a68cc
2
src/backend/utils/cache/relcache.c
vendored
2
src/backend/utils/cache/relcache.c
vendored
@ -6083,7 +6083,7 @@ write_item(const void *data, Size len, FILE *fp)
|
|||||||
{
|
{
|
||||||
if (fwrite(&len, 1, sizeof(len), fp) != sizeof(len))
|
if (fwrite(&len, 1, sizeof(len), fp) != sizeof(len))
|
||||||
elog(FATAL, "could not write init file");
|
elog(FATAL, "could not write init file");
|
||||||
if (fwrite(data, 1, len, fp) != len)
|
if (len > 0 && fwrite(data, 1, len, fp) != len)
|
||||||
elog(FATAL, "could not write init file");
|
elog(FATAL, "could not write init file");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user