summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-12-18 16:32:04 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-12-18 16:32:04 +0100
commitf008aec73bf108fc4f27c22d89704fb3c9572b97 (patch)
tree7041ce382aa9585776e544017cc3d1982531f859 /src
parent6681beca6444a48d6e939cb1acdae8332ef548ad (diff)
downloaddabmux-f008aec73bf108fc4f27c22d89704fb3c9572b97.tar.gz
dabmux-f008aec73bf108fc4f27c22d89704fb3c9572b97.tar.bz2
dabmux-f008aec73bf108fc4f27c22d89704fb3c9572b97.zip
Fix error handling in dmb UDP input
Diffstat (limited to 'src')
-rw-r--r--src/dabInputDmbUdp.cpp15
1 files 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;;