commit 6fa47d8acc71079130a4f02a0dc5becaadb9446d
parent 1181f79edafa099b8b935a3c49cb3d3b35482662
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Thu, 3 Aug 2023 18:48:36 +0200
-fix FD leak
Diffstat:
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_spa.c b/src/backend/taler-merchant-httpd_spa.c
@@ -118,13 +118,7 @@ static enum GNUNET_GenericReturnValue
build_webui (void *cls,
const char *dn)
{
- int fd;
- struct stat sb;
- struct MHD_Response *zspa = NULL;
- struct MHD_Response *spa;
- const char *ext;
- const char *mime;
- struct
+ static struct
{
const char *ext;
const char *mime;
@@ -162,6 +156,12 @@ build_webui (void *cls,
.mime = NULL
},
};
+ int fd;
+ struct stat sb;
+ struct MHD_Response *zspa = NULL;
+ struct MHD_Response *spa;
+ const char *ext;
+ const char *mime;
(void) cls;
/* finally open template */
@@ -188,8 +188,10 @@ build_webui (void *cls,
mime = NULL;
ext = strrchr (dn, '.');
if (NULL == ext)
+ {
+ GNUNET_break (0 == close (fd));
return GNUNET_OK;
-
+ }
ext++;
for (unsigned int i = 0; NULL != mime_map[i].ext; i++)
if (0 == strcasecmp (ext,