From f008aec73bf108fc4f27c22d89704fb3c9572b97 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 18 Dec 2015 16:32:04 +0100 Subject: Fix error handling in dmb UDP input --- src/dabInputDmbUdp.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/dabInputDmbUdp.cpp b/src/dabInputDmbUdp.cpp index e67f90f..3609de2 100644 --- a/src/dabInputDmbUdp.cpp +++ b/src/dabInputDmbUdp.cpp @@ -76,13 +76,23 @@ int dabInputDmbUdpOpen(void* args, const char* inputName) char* address; char* ptr; long port; - address = strdup(inputName); + dabInputDmbUdpData* input = (dabInputDmbUdpData*)args; + + // Skip the udp:// part if it is present + if (strncmp(inputName, "udp://", 6) == 0) { + address = strdup(inputName + 6); + } + else { + address = strdup(inputName); + } + ptr = strchr(address, ':'); if (ptr == NULL) { etiLog.log(error, "\"%s\" is an invalid format for udp address: " "should be [address]:port - > aborting\n", address); returnCode = -1; + goto dmbudpopen_ptr_null_out; } *(ptr++) = 0; port = strtol(ptr, (char **)NULL, 10); @@ -96,7 +106,7 @@ int dabInputDmbUdpOpen(void* args, const char* inputName) etiLog.log(error, "can't use port number 0 in udp address\n"); returnCode = -1; } - dabInputDmbUdpData* input = (dabInputDmbUdpData*)args; + if (input->socket->create(port) == -1) { etiLog.log(error, "can't set port %i on Dmb input (%s: %s)\n", port, inetErrDesc, inetErrMsg); @@ -118,6 +128,7 @@ int dabInputDmbUdpOpen(void* args, const char* inputName) returnCode = -1; } +dmbudpopen_ptr_null_out: free(address); etiLog.log(debug, "check return code of create\n"); return returnCode;; -- cgit v1.2.3