diff options
author | Andres Freund <andres@anarazel.de> | 2022-03-23 13:05:25 -0700 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2022-03-23 13:13:49 -0700 |
commit | 5f4615b9def5c7a4218c7e17f318e4b2eb2b1747 (patch) | |
tree | bff48acc47281527c6a074101b81b663bd2c3ab2 | |
parent | 2a919372655d64a5ed848b84a09b54d685aec446 (diff) |
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 46ab07ffda9.
Discussion: https://postgr.es/m/20220323173537.ll7klrglnp4gn2um@alap3.anarazel.de
Backpatch: 10-
-rw-r--r-- | src/backend/utils/cache/relcache.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 7dc28b8d39d..314b9fd3456 100644 --- 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"); } |