Переглянути джерело

libdpkg: Refactor tar_entry destruction into new tar_entry_destroy()

Guillem Jover 14 роки тому
батько
коміт
a8c489ae5f
1 змінених файлів з 10 додано та 5 видалено
  1. 10 5
      lib/dpkg/tarfn.c

+ 10 - 5
lib/dpkg/tarfn.c

@@ -3,7 +3,7 @@
  * tarfn.c - tar archive extraction functions
  *
  * Copyright © 1995 Bruce Perens
- * Copyright © 2007-2010 Guillem Jover <guillem@debian.org>
+ * Copyright © 2007-2011 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -266,6 +266,13 @@ tar_gnu_long(void *ctx, const struct tar_operations *ops, struct tar_entry *te,
 	return status;
 }
 
+static void
+tar_entry_destroy(struct tar_entry *te)
+{
+	free(te->name);
+	free(te->linkname);
+}
+
 struct symlinkList {
 	struct symlinkList *next;
 	struct tar_entry h;
@@ -380,13 +387,11 @@ tar_extractor(void *ctx, const struct tar_operations *ops)
 		symlink_node = symlink_head->next;
 		if (status == 0)
 			status = ops->symlink(ctx, &symlink_head->h);
-		free(symlink_head->h.name);
-		free(symlink_head->h.linkname);
+		tar_entry_destroy(&symlink_head->h);
 		free(symlink_head);
 		symlink_head = symlink_node;
 	}
-	free(h.name);
-	free(h.linkname);
+	tar_entry_destroy(&h);
 
 	if (status > 0) {
 		/* Indicates broken tarfile: “Read partial header record”. */