diff options
author | Sanjay Kumar <sanjay.pec@gmail.com> | 2017-08-05 23:52:49 +0530 |
---|---|---|
committer | Sanjay Kumar <sanjay.pec@gmail.com> | 2017-08-05 23:52:49 +0530 |
commit | 0abcbce3bbae7e1068caacedbccc1563ff005df4 (patch) | |
tree | 7b5e29345077d0b8bfe745f90a90e80eb73b2924 | |
parent | 4947f9a19377ff3f2859915b4dec570e67e47757 (diff) | |
download | jansson-0abcbce3bbae7e1068caacedbccc1563ff005df4.zip jansson-0abcbce3bbae7e1068caacedbccc1563ff005df4.tar.gz jansson-0abcbce3bbae7e1068caacedbccc1563ff005df4.tar.bz2 |
json_dump_file API returns success even when fclose fails (consider disk full case). API should check the return value of fclose before returning success to its caller. fwrite may not write anything into the file, it simply returns the number of bytes written into the buffer. When disk is full and fclose is called, it results in truncation of the file (resulting in zero sized file). Since, API is returning success, its caller can't take any remedial action on its failure.
-rw-r--r-- | src/dump.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -481,7 +481,9 @@ int json_dump_file(const json_t *json, const char *path, size_t flags) result = json_dumpf(json, output, flags); - fclose(output); + if(fclose(output) != 0) + return -1; + return result; } |