fix services.c segfault
authorPavel Šimerda <psimerda@redhat.com>
Sat, 8 Feb 2014 15:47:47 +0000 (16:47 +0100)
committerPavel Šimerda <psimerda@redhat.com>
Sat, 8 Feb 2014 15:47:47 +0000 (16:47 +0100)
lib/services.c

index 67c900475dea6ee4d888bef74d80937143e80d31..71fb777e54f330d8be634a111f5c3327d33a6877 100644 (file)
@@ -79,7 +79,8 @@ add_service(int protocol, int port, const char *name)
        memset(&service, 0, sizeof service);
        service.protocol = protocol;
        service.port = port;
-       service.name = strdup(name);
+       if (name)
+               service.name = strdup(name);
 
        if (servicecount == servicereservedcount) {
                if (!servicereservedcount)
@@ -155,7 +156,7 @@ read_services(void)
        }
 out:
        close(fd);
-       add_service(0, 0, "");
+       add_service(0, 0, NULL);
        servicereservedcount = servicecount;
        services = realloc(services, servicereservedcount * sizeof *services);
 }
This page took 0.066098 seconds and 5 git commands to generate.