瀏覽代碼

Fix another memory leak

This one occurs when changing configuration options. Found by
coverity.
Nick Mathewson 11 年之前
父節點
當前提交
afca9ab14e
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      src/or/config.c

+ 4 - 1
src/or/config.c

@@ -777,9 +777,12 @@ set_options(or_options_t *new_val, char **msg)
         line = get_assigned_option(&options_format, new_val, var_name, 1);
 
         if (line) {
-          for (; line; line = line->next) {
+          config_line_t *next;
+          for (; line; line = next) {
+            next = line->next;
             smartlist_add(elements, line->key);
             smartlist_add(elements, line->value);
+            tor_free(line);
           }
         } else {
           smartlist_add(elements, (char*)options_format.vars[i].name);