Quellcode durchsuchen

Backport candidate: remove dangerous free(0) on hashtable init

svn:r8499
Nick Mathewson vor 17 Jahren
Ursprung
Commit
0f8491a254
2 geänderte Dateien mit 4 neuen und 1 gelöschten Zeilen
  1. 2 0
      ChangeLog
  2. 2 1
      src/common/ht.h

+ 2 - 0
ChangeLog

@@ -53,6 +53,8 @@ Changes in version 0.1.2.2-alpha - 2006-??-??
     - If we're a directory mirror and we ask for "all" network status
       documents, we would discard status documents from authorities
       we don't recognize.
+    - Avoid a memory corruption bug when creating a hash table for the first
+      time.
 
   o Documentation
     - Documented (and renamed) ServerDNSSearchDomains and

+ 2 - 1
src/common/ht.h

@@ -307,7 +307,8 @@ ht_string_hash(const char *s)
           elm = next;                                                   \
         }                                                               \
       }                                                                 \
-      freefn(head->hth_table);                                          \
+      if (head->hth_table)                                              \
+        freefn(head->hth_table);                                        \
       head->hth_table = new_table;                                      \
     } else {                                                            \
       unsigned b, b2;                                                   \