aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2018-03-16 00:05:27 +0100
committercbdev <cb@cbcdn.com>2018-03-16 00:05:27 +0100
commit5df6379df17fd7875e54ef7c5b5d07c5edb95644 (patch)
tree88c9542a514c65733dd3ae3b1031b25d7e8189fc
parent117946a832cc2cb3f8e02d1f4cbc65e3ca3279ef (diff)
downloadmidimonster-5df6379df17fd7875e54ef7c5b5d07c5edb95644.tar.gz
midimonster-5df6379df17fd7875e54ef7c5b5d07c5edb95644.tar.bz2
midimonster-5df6379df17fd7875e54ef7c5b5d07c5edb95644.zip
Fix resource leaks on error
-rw-r--r--backends/artnet.c1
-rw-r--r--backends/sacn.c1
-rw-r--r--config.c2
3 files changed, 4 insertions, 0 deletions
diff --git a/backends/artnet.c b/backends/artnet.c
index c16e630..d167dec 100644
--- a/backends/artnet.c
+++ b/backends/artnet.c
@@ -83,6 +83,7 @@ static int artnet_listener(char* host, char* port){
//store fd
artnet_fd = realloc(artnet_fd, (artnet_fds + 1) * sizeof(artnet_descriptor));
if(!artnet_fd){
+ close(fd);
fprintf(stderr, "Failed to allocate memory\n");
return -1;
}
diff --git a/backends/sacn.c b/backends/sacn.c
index 9a3202d..57ac789 100644
--- a/backends/sacn.c
+++ b/backends/sacn.c
@@ -117,6 +117,7 @@ static int sacn_listener(char* host, char* port, uint8_t fd_flags){
//store fd
global_cfg.fd = realloc(global_cfg.fd, (global_cfg.fds + 1) * sizeof(sacn_fd));
if(!global_cfg.fd){
+ close(fd);
fprintf(stderr, "Failed to allocate memory\n");
return -1;
}
diff --git a/config.c b/config.c
index f03d98a..b81aeaf 100644
--- a/config.c
+++ b/config.c
@@ -43,6 +43,8 @@ static int config_map(char* to_raw, char* from_raw){
int rv = 1;
if(!from || !to){
+ free(from);
+ free(to);
fprintf(stderr, "Failed to allocate memory\n");
return 1;
}