s3: Fix crash in free_file_list().
authorBo Yang <boyang@samba.org>
Mon, 30 Nov 2009 09:30:25 +0000 (17:30 +0800)
committerBo Yang <boyang@samba.org>
Mon, 30 Nov 2009 11:22:47 +0000 (19:22 +0800)
Signed-off-by: Bo Yang <boyang@samba.org>
source3/param/loadparm.c

index 29e3a25..a1f5328 100644 (file)
@@ -7016,6 +7016,7 @@ static void add_to_file_list(const char *fname, const char *subfname)
                }
                f->subfname = SMB_STRDUP(subfname);
                if (!f->subfname) {
+                       SAFE_FREE(f->name);
                        SAFE_FREE(f);
                        return;
                }
@@ -7026,6 +7027,7 @@ static void add_to_file_list(const char *fname, const char *subfname)
                if (t)
                        f->modtime = t;
        }
+       return;
 }
 
 /**
@@ -7113,9 +7115,8 @@ bool lp_file_list_changed(void)
                                          ctime(&mod_time)));
                                f->modtime = mod_time;
                                SAFE_FREE(f->subfname);
-                               f->subfname = n2; /* Passing ownership of
-                                                    return from alloc_sub_basic
-                                                    above. */
+                               f->subfname = SMB_STRDUP(n2);
+                               TALLOC_FREE(n2);
                                return true;
                        }
                        TALLOC_FREE(n2);