aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2020-04-19 21:11:28 +0200
committercbdev <cb@cbcdn.com>2020-04-19 21:11:28 +0200
commita3a79b824a1936868ba4ab5be53998593b0e9047 (patch)
treee48dd0fa1994ad9c502b930ff6f20351e87b5206
parentea123f01f769b90b31b4bc78e2bdff5517e7e8de (diff)
downloadmidimonster-a3a79b824a1936868ba4ab5be53998593b0e9047.tar.gz
midimonster-a3a79b824a1936868ba4ab5be53998593b0e9047.tar.bz2
midimonster-a3a79b824a1936868ba4ab5be53998593b0e9047.zip
Fix Coverity issues
-rw-r--r--backends/rtpmidi.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/backends/rtpmidi.c b/backends/rtpmidi.c
index 443967d..af90f27 100644
--- a/backends/rtpmidi.c
+++ b/backends/rtpmidi.c
@@ -164,7 +164,7 @@ static int dns_encode_name(char* name, dns_name* out){
for(token = strtok_r(name, ".", &save); token; token = strtok_r(NULL, ".", &save)){
//make space for this label, its length and a trailing root label
- if(out->alloc < out->length + strlen(token) + 1 + 1){
+ if(out->alloc < out->length + strlen(token) + 1 + 1 || !out->name){
out->name = realloc(out->name, (out->length + strlen(token) + 2) * sizeof(char));
if(!out->name){
LOG("Failed to allocate memory");
@@ -319,7 +319,7 @@ static int rtpmidi_announce_addrs(){
}
static uint32_t rtpmidi_interval(){
- return max(0, RTPMIDI_SERVICE_INTERVAL - (mm_timestamp() - cfg.last_service));
+ return max(0, (int64_t) RTPMIDI_SERVICE_INTERVAL - (int64_t) (mm_timestamp() - cfg.last_service));
}
static int rtpmidi_configure(char* option, char* value){
@@ -1526,20 +1526,16 @@ static int rtpmidi_handle_mdns(){
free(name.name);
free(host.name);
- if(bytes <= 0){
- #ifdef _WIN32
- if(WSAGetLastError() == WSAEWOULDBLOCK){
- #else
- if(errno == EAGAIN){
- #endif
- return 0;
- }
-
- LOGPF("Error reading from mDNS descriptor: %s", mmbackend_socket_strerror(errno));
- return 1;
+ #ifdef _WIN32
+ if(WSAGetLastError() == WSAEWOULDBLOCK){
+ #else
+ if(errno == EAGAIN){
+ #endif
+ return 0;
}
- return 0;
+ LOGPF("Error reading from mDNS descriptor: %s", mmbackend_socket_strerror(errno));
+ return 1;
}
static int rtpmidi_handle(size_t num, managed_fd* fds){