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 0c7bb5ae5eaf68074213037fab4787ba492fc0dd..4496bfd098f26a836cc158062e020839a20f99a9 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;
 }