- fix segfault in reset_ino_dev_hashtable() when *hashtable was null.
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Thu, 5 Apr 2007 09:21:24 +0000 (09:21 -0000)
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Thu, 5 Apr 2007 09:21:24 +0000 (09:21 -0000)
  Seen in the testsuite for du -l .../testsuite on exit with CLEAN_UP enabled.

coreutils/du.c
libbb/inode_hash.c

index e5fe5ffe2d1272756acc62dfd87813598b5fed0e..e95f3a2f14b32792a7d85decebf02d5146f01893 100644 (file)
@@ -235,10 +235,8 @@ int du_main(int argc, char **argv)
                total += du(*argv);
                slink_depth = slink_depth_save;
        } while (*++argv);
-#if ENABLE_FEATURE_CLEAN_UP
-       reset_ino_dev_hashtable();
-#endif
-
+       if (ENABLE_FEATURE_CLEAN_UP)
+               reset_ino_dev_hashtable();
        if (print_final_total) {
                print(total, "total");
        }
index 0705102b8c484ff69a162de23e1bfc3c8a607cf8..78c1b0f9e929865ea9c720d3c5f30a0d9ac8fbb5 100644 (file)
@@ -77,7 +77,7 @@ void reset_ino_dev_hashtable(void)
        int i;
        ino_dev_hashtable_bucket_t *bucket;
 
-       for (i = 0; i < HASH_SIZE; i++) {
+       for (i = 0; ino_dev_hashtable && i < HASH_SIZE; i++) {
                while (ino_dev_hashtable[i] != NULL) {
                        bucket = ino_dev_hashtable[i]->next;
                        free(ino_dev_hashtable[i]);
@@ -87,4 +87,6 @@ void reset_ino_dev_hashtable(void)
        free(ino_dev_hashtable);
        ino_dev_hashtable = NULL;
 }
+#else
+void reset_ino_dev_hashtable(void);
 #endif