From f50e5c42b4b97644aa071e6aaaf0d82b2568d612 Mon Sep 17 00:00:00 2001 From: ngn Date: Mon, 1 Jul 2024 06:54:44 +0300 Subject: [PATCH] fix: close forgotten open file descriptors for recvfile and sendfile --- src/mptp/{utils.c => util.c} | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) rename src/mptp/{utils.c => util.c} (96%) diff --git a/src/mptp/utils.c b/src/mptp/util.c similarity index 96% rename from src/mptp/utils.c rename to src/mptp/util.c index 13e1b62..a3c4530 100644 --- a/src/mptp/utils.c +++ b/src/mptp/util.c @@ -35,11 +35,12 @@ bool lm_mptp_sendfile(int sock, struct sockaddr *addr, char *path){ lm_mptp_init(&packet, false, MPTP_S2C_COOL, false); } - fclose(file); lm_mptp_init(&packet, false, MPTP_S2C_COOL, true); ret = true; end: + if(NULL != file) + fclose(file); lm_mptp_server_send(sock, &packet, addr); return ret; } @@ -85,6 +86,7 @@ bool lm_mptp_recvfile(int sock, char *path){ ret = true; end: - fclose(file); + if(NULL != file) + fclose(file); return ret; }