Do not leak opened file, from lg65438805 at gmail dot com in GitHub

issue 4577.
This commit is contained in:
nicm
2025-08-14 06:37:29 +00:00
parent 3ae0d560be
commit 4ce893ebc0

5
file.c
View File

@ -364,7 +364,7 @@ file_read(struct client *c, const char *path, client_file_cb cb, void *cbdata)
size_t msglen;
int fd = -1;
u_int stream = file_next_stream++;
FILE *f;
FILE *f = NULL;
size_t size;
char buffer[BUFSIZ];
@ -404,7 +404,6 @@ file_read(struct client *c, const char *path, client_file_cb cb, void *cbdata)
cf->error = EIO;
goto done;
}
fclose(f);
goto done;
}
@ -427,6 +426,8 @@ skip:
return cf;
done:
if (f != NULL)
fclose(f);
file_fire_done(cf);
return NULL;
}