projects
/
postgresql.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
2a91937
)
Don't call fwrite() with len == 0 when writing out relcache init file.
author
Andres Freund
<
[email protected]
>
Wed, 23 Mar 2022 20:05:25 +0000
(13:05 -0700)
committer
Andres Freund
<
[email protected]
>
Wed, 23 Mar 2022 20:13:49 +0000
(13:13 -0700)
Noticed via -fsanitize=undefined.
Backpatch to all branches, for the same reasons as
46ab07ffda9
.
Discussion: https://postgr.es/m/
20220323173537
[email protected]
Backpatch: 10-
src/backend/utils/cache/relcache.c
patch
|
blob
|
blame
|
history
diff --git
a/src/backend/utils/cache/relcache.c
b/src/backend/utils/cache/relcache.c
index 7dc28b8d39d02d6c713c8c753fb053b9af9dffe4..314b9fd345620f74097e6a092f276659e66d50d5 100644
(file)
--- a/
src/backend/utils/cache/relcache.c
+++ b/
src/backend/utils/cache/relcache.c
@@
-6194,7
+6194,7
@@
write_item(const void *data, Size len, FILE *fp)
{
if (fwrite(&len, 1, sizeof(len), fp) != sizeof(len))
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");
}