mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 08:08:53 -05:00
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
This commit is contained in:
parent
157e5d47b5
commit
1c48d3dab2
@ -1120,7 +1120,10 @@ struct rewriteConfigState *rewriteConfigReadOldFile(char *path) {
|
|||||||
if (fp == NULL && errno != ENOENT) return NULL;
|
if (fp == NULL && errno != ENOENT) return NULL;
|
||||||
|
|
||||||
struct redis_stat sb;
|
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;
|
int linenum = -1;
|
||||||
struct rewriteConfigState *state = rewriteConfigCreateState();
|
struct rewriteConfigState *state = rewriteConfigCreateState();
|
||||||
|
Loading…
Reference in New Issue
Block a user