diff options
| author | Andres Freund | 2022-03-23 20:05:25 +0000 |
|---|---|---|
| committer | Andres Freund | 2022-03-23 20:13:40 +0000 |
| commit | 2121d58091a3d6b53299d774f318cbdfb96076be (patch) | |
| tree | 6974a1eee2529b048349fe44132d94d2c44b6baa /src | |
| parent | a77dddb42e0916f8c0962b758668d49e8fd81cc8 (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-
Diffstat (limited to 'src')
| -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 b7907771083..0524cb8541f 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -6168,7 +6168,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"); } |
