Unverified Commit 1c48d3da authored by Moshe Kaplan's avatar Moshe Kaplan Committed by GitHub
Browse files

config.c: Avoid leaking file handle if redis_fstat() fails (#12796)

If fopen() is successful, but redis_fstat() fails, the file handle
stored in fp will leak. This change closes the filehandle stored in fp
if redis_fstat() fails.

Fixes Coverity 390029
parent 157e5d47
......@@ -1120,7 +1120,10 @@ struct rewriteConfigState *rewriteConfigReadOldFile(char *path) {
if (fp == NULL && errno != ENOENT) return NULL;
struct redis_stat sb;
if (fp && redis_fstat(fileno(fp),&sb) == -1) return NULL;
if (fp && redis_fstat(fileno(fp),&sb) == -1) {
fclose(fp);
return NULL;
}
int linenum = -1;
struct rewriteConfigState *state = rewriteConfigCreateState();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment