]> granicus.if.org Git - libnl/commitdiff
Properly handle addr=NULL in nl_addr2str
authorThomas Graf <tgr@lsx.localdomain>
Fri, 13 Jun 2008 14:39:35 +0000 (16:39 +0200)
committerThomas Graf <tgr@lsx.localdomain>
Fri, 13 Jun 2008 14:39:35 +0000 (16:39 +0200)
lib/addr.c

index 1d3460e75c3c0c252404edbfa74bdbc603c6c2c2..d5af9a54b8c3cfb098deb588a7e59b3faf7fe97f 100644 (file)
@@ -832,9 +832,12 @@ char *nl_addr2str(struct nl_addr *addr, char *buf, size_t size)
        int i;
        char tmp[16];
 
-       if (!addr->a_len) {
+       if (!addr || !addr->a_len) {
                snprintf(buf, size, "none");
-               goto prefix;
+               if (addr)
+                       goto prefix;
+               else
+                       return buf;
        }
 
        switch (addr->a_family) {