aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2018-03-16 01:18:35 +0100
committercbdev <cb@cbcdn.com>2018-03-16 01:18:35 +0100
commiteabc4d0e07d2fb2f2a9aaf2571af490ec7e55b7d (patch)
treeeb3ee0aa6178e10d2ddef38f2921fa63d09a1fd2
parent5df6379df17fd7875e54ef7c5b5d07c5edb95644 (diff)
downloadmidimonster-eabc4d0e07d2fb2f2a9aaf2571af490ec7e55b7d.tar.gz
midimonster-eabc4d0e07d2fb2f2a9aaf2571af490ec7e55b7d.tar.bz2
midimonster-eabc4d0e07d2fb2f2a9aaf2571af490ec7e55b7d.zip
Fix issues found by Coverity Scan
-rw-r--r--backends/artnet.c1
-rw-r--r--backends/evdev.c1
-rw-r--r--backends/osc.c7
-rw-r--r--midimonster.h1
-rw-r--r--plugin.c1
5 files changed, 9 insertions, 2 deletions
diff --git a/backends/artnet.c b/backends/artnet.c
index d167dec..f98ae96 100644
--- a/backends/artnet.c
+++ b/backends/artnet.c
@@ -489,6 +489,7 @@ static int artnet_start(){
}
if(!artnet_fds){
+ free(inst);
fprintf(stderr, "Failed to start ArtNet backend: no descriptors bound\n");
return 1;
}
diff --git a/backends/evdev.c b/backends/evdev.c
index e26eb76..979698f 100644
--- a/backends/evdev.c
+++ b/backends/evdev.c
@@ -359,6 +359,7 @@ static int evdev_start(){
if(data->output_enabled){
if(libevdev_uinput_create_from_device(data->output_proto, LIBEVDEV_UINPUT_OPEN_MANAGED, &data->output_ev)){
fprintf(stderr, "Failed to create evdev output device: %s\n", strerror(errno));
+ free(inst);
return 1;
}
fprintf(stderr, "Created device node %s for instance %s\n", libevdev_uinput_get_devnode(data->output_ev), inst[u]->name);
diff --git a/backends/osc.c b/backends/osc.c
index adc91f5..5f94ec2 100644
--- a/backends/osc.c
+++ b/backends/osc.c
@@ -334,6 +334,7 @@ static int osc_listener(char* host, char* port){
//set nonblocking
flags = fcntl(fd, F_GETFL, 0);
if(fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0){
+ close(fd);
fprintf(stderr, "Failed to set OSC descriptor nonblocking\n");
return -1;
}
@@ -697,7 +698,7 @@ static int backend_handle(size_t num, managed_fd* fds){
else{
bytes_read = recv(fds[fd].fd, recv_buf, sizeof(recv_buf), 0);
}
- if(data->root && strncmp(recv_buf, data->root, strlen(data->root))){
+ if(data->root && strncmp(recv_buf, data->root, min(bytes_read, strlen(data->root)))){
//ignore packet for different root
continue;
}
@@ -802,7 +803,9 @@ static int backend_shutdown(){
}
free(data->channel);
free(data->root);
- close(data->fd);
+ if(data->fd >= 0){
+ close(data->fd);
+ }
data->fd = -1;
data->channels = 0;
free(inst[u]->impl);
diff --git a/midimonster.h b/midimonster.h
index 9f1a33e..0b794f3 100644
--- a/midimonster.h
+++ b/midimonster.h
@@ -4,6 +4,7 @@
#include <stdlib.h>
#include <stdint.h>
#define max(a,b) (((a) > (b)) ? (a) : (b))
+#define min(a,b) (((a) < (b)) ? (a) : (b))
#ifdef DEBUG
#define DBGPF(format, ...) fprintf(stderr, (format), __VA_ARGS__)
#define DBG(message) fprintf(stderr, "%s", (message))
diff --git a/plugin.c b/plugin.c
index 39a92be..7b5e922 100644
--- a/plugin.c
+++ b/plugin.c
@@ -40,6 +40,7 @@ static int plugin_attach(char* path, char* file){
}
}
else{
+ free(lib);
return 0;
}
free(lib);