Free memory used when parsing a control file.
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 2 Nov 2009 01:35:48 +0000 (01:35 +0000)
committergraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 2 Nov 2009 01:35:48 +0000 (01:35 +0000)
git-svn-id: http://opkg.googlecode.com/svn/trunk@234 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/pkg.c

index 0c7bb5a..4496bfd 100644 (file)
@@ -284,7 +284,7 @@ void pkg_deinit(pkg_t *pkg)
 int pkg_init_from_file(pkg_t *pkg, const char *filename)
 {
      int err;
-     char **raw;
+     char **raw, **raw_start;
      FILE *control_file;
 
      err = pkg_init(pkg);
@@ -297,11 +297,17 @@ int pkg_init_from_file(pkg_t *pkg, const char *filename)
      if (err) { return err; }
 
      rewind(control_file);
-     raw = read_raw_pkgs_from_stream(control_file);
+     raw = raw_start = read_raw_pkgs_from_stream(control_file);
      pkg_parse_raw(pkg, &raw, NULL, NULL);
 
      fclose(control_file);
 
+     raw = raw_start;
+     while (*raw) {
+         free(*raw++);
+     }
+     free(raw_start);
+
      return 0;
 }