httpinfo: fix a segfault when PUD is not loaded
authorFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 24 May 2012 07:36:51 +0000 (09:36 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 24 May 2012 07:37:19 +0000 (09:37 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/httpinfo/src/olsrd_httpinfo.c

index f05e143..c87e1e1 100644 (file)
@@ -1174,7 +1174,7 @@ static bool nmea_INFO_has_field_local(int smask, nmeaINFO_FIELD fieldName) {
 
 static void build_pud_body(struct autobuf *abuf) {
        TransmitGpsInformation * txGpsInfo = olsr_cnf->pud_position;
-       char * nodeId = (char *) txGpsInfo->nodeId;
+       char * nodeId;
        char nodeIdString[1024];
 
        if (!txGpsInfo) {
@@ -1182,6 +1182,8 @@ static void build_pud_body(struct autobuf *abuf) {
                return;
        }
 
+       nodeId = (char *) txGpsInfo->nodeId;
+
        if (!txGpsInfo->nodeId || !strlen((char *) txGpsInfo->nodeId)) {
                inet_ntop(olsr_cnf->ip_version, &olsr_cnf->main_addr, &nodeIdString[0], sizeof(nodeIdString));
                nodeId = nodeIdString;