rdb.c: Avoid potential file handle leak (Coverity 404720) (#12795)
`open()` can return any non-negative integer on success, including zero. This change modifies the check from open()'s return value to also include checking for a return value of zero (e.g., if stdin were closed and then `open()` was called). Fixes Coverity 404720 Can't happen in Redis. just a cleanup.
This commit is contained in:
parent
ae09d4d3ef
commit
c9aa586b6b
@ -3442,7 +3442,7 @@ int rdbLoad(char *filename, rdbSaveInfo *rsi, int rdbflags) {
|
|||||||
if (retval == C_OK && !(rdbflags & RDBFLAGS_KEEP_CACHE)) {
|
if (retval == C_OK && !(rdbflags & RDBFLAGS_KEEP_CACHE)) {
|
||||||
/* TODO: maybe we could combine the fopen and open into one in the future */
|
/* TODO: maybe we could combine the fopen and open into one in the future */
|
||||||
rdb_fd = open(filename, O_RDONLY);
|
rdb_fd = open(filename, O_RDONLY);
|
||||||
if (rdb_fd > 0) bioCreateCloseJob(rdb_fd, 0, 1);
|
if (rdb_fd >= 0) bioCreateCloseJob(rdb_fd, 0, 1);
|
||||||
}
|
}
|
||||||
return (retval==C_OK) ? RDB_OK : RDB_FAILED;
|
return (retval==C_OK) ? RDB_OK : RDB_FAILED;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user