Explorar el Código

u-a: Fix memory leaks in alternative_parse_fileset()

Free prio_str and master_file.

Warned-by: coverity
Guillem Jover hace 12 años
padre
commit
2579acce1f
Se han modificado 2 ficheros con 5 adiciones y 0 borrados
  1. 1 0
      debian/changelog
  2. 4 0
      utils/update-alternatives.c

+ 1 - 0
debian/changelog

@@ -10,6 +10,7 @@ dpkg (1.17.9) UNRELEASED; urgency=low
   * Fix short lived memory leaks in «dpkg-split --split».
   * Fix memory leak in unused Keybindings screen in dselect.
   * Do not leak color string on «dselect --color».
+  * Fix memory leaks when parsing alternatives.
 
   [ Updated scripts translations ]
   * French (Steve Petruzzello). Closes: #746350

+ 4 - 0
utils/update-alternatives.c

@@ -1262,6 +1262,8 @@ alternative_parse_fileset(struct alternative *a, struct altdb_context *ctx)
 			ctx->bad_format(ctx,
 			                _("priority of %s is out of range: %s"),
 			                master_file, prio_str);
+		free(prio_str);
+
 		fs = fileset_new(master_file, prio);
 		for (sl = a->slaves; sl; sl = sl->next) {
 			fileset_add_slave(fs, xstrdup(sl->name),
@@ -1269,6 +1271,8 @@ alternative_parse_fileset(struct alternative *a, struct altdb_context *ctx)
 		}
 		alternative_add_choice(a, fs);
 	}
+	free(master_file);
+
 	return true;
 }