]> git.ipfire.org Git - thirdparty/libnl.git/commitdiff
Handle the case where nl_msec2str is passed 0 msecs
authorJoe Damato <ice799@gmail.com>
Fri, 19 Jul 2013 05:35:45 +0000 (22:35 -0700)
committerJoe Damato <ice799@gmail.com>
Fri, 19 Jul 2013 09:06:27 +0000 (02:06 -0700)
lib/utils.c

index 234e0defd0a349c03a71e90e2025e0d947e925fb..c04d83fb481b7ad69103eb661d35f8b785f87f41 100644 (file)
@@ -559,6 +559,11 @@ char * nl_msec2str(uint64_t msec, char *buf, size_t len)
 #undef  _SPLIT
        split[4] = msec;
 
+       if (msec == 0) {
+               snprintf(buf, len, "0msec");
+               return buf_orig;
+       }
+
        for (i = 0; i < ARRAY_SIZE(split) && len; i++) {
                int l;
                if (split[i] == 0)