From 50be29ad1860d6748c4c6b3b5707a2ffbb310b11 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 20 Aug 2024 10:55:01 +0200 Subject: [PATCH] modules-sap: fix uninitialized variable when close in error --- src/modules/module-rtp-sap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/module-rtp-sap.c b/src/modules/module-rtp-sap.c index 86b6b9c91..ec5910a8b 100644 --- a/src/modules/module-rtp-sap.c +++ b/src/modules/module-rtp-sap.c @@ -1488,7 +1488,7 @@ on_sap_io(void *data, int fd, uint32_t mask) static int start_sap(struct impl *impl) { - int fd, res; + int fd = -1, res; struct timespec value, interval; char addr[128] = "invalid"; @@ -1528,7 +1528,8 @@ static int start_sap(struct impl *impl) return 0; error: - close(fd); + if (fd > 0) + close(fd); return res; }