[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#193528: main-menu: The actual patch



Package: main-menu
Version: 0.029 (not installed)
Followup-For: Bug #193528

Um... yeah. You know you're tired when you forget to attach the actual
patch. Here it is.

 - David Nusinow

-- System Information:
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux polymerase 2.4.20 #1 Tue Dec 17 00:00:32 PST 2002 i686
Locale: LANG=C, LC_CTYPE=C

--- main-menu.c	2003-05-16 00:27:00.000000000 -0700
+++ mymain-menu.c	2003-05-16 00:17:18.000000000 -0700
@@ -54,9 +54,13 @@
 	struct stat statbuf;
 	int ret;
 
-	asprintf(&menutest, DPKGDIR "info/%s.menutest", p->package);
+	if (asprintf(&menutest, DPKGDIR "info/%s.menutest", p->package) == -1) {
+		return 1;
+	}
 	if (stat(menutest, &statbuf) == 0) {
-		asprintf(&cmd, "%s >/dev/null 2>&1", menutest);
+		if (asprintf(&cmd, "%s >/dev/null 2>&1", menutest) == -1) {
+			return 1;
+		}
 		ret = !SYSTEM(cmd);
 		free(cmd);
 	}
@@ -227,7 +231,9 @@
 	size_t c_size = 1;
 	int is_menu_item = 0;
 
-        asprintf(&choices, "");
+        if (asprintf(&choices, "") == -1) {
+		return 1;
+	}
 	/* Compile a list of providing package. The default choice will be the
 	 * package with highest priority. If we have ties, menu items are
 	 * preferred. If we still have ties, the default choice is arbitrary */
@@ -254,11 +260,16 @@
 		 * is a menu item */
 		if (dep->installer_menu_item)
 			is_menu_item = 1;
-		if (dep == defpkg)
+		if (dep == defpkg) {
 			/* We want the default to be the first item */
-			asprintf(&tmp, "%s, %s", dep->description, choices);
-		else
-			asprintf(&tmp, "%s%s, ", choices, dep->description);
+			if (asprintf(&tmp, "%s, %s", dep->description, choices) == -1) {
+				return 1;
+			}
+		} else {
+			if (asprintf(&tmp, "%s%s, ", choices, dep->description) == -1) {
+				return 1;
+			}
+		}
 		free(choices);
 		choices = tmp;
 	}
@@ -365,7 +376,9 @@
 			return 0;
 	}
 
-	asprintf(&configcommand, DPKG_CONFIGURE_COMMAND " %s", p->package);
+	if (asprintf(&configcommand, DPKG_CONFIGURE_COMMAND " %s", p->package) == -1) {
+		return 1;
+	}
 	ret = SYSTEM(configcommand);
 	free(configcommand);
         if (ret == 0) {
@@ -394,7 +407,9 @@
 
 	if (p->status == installed) {
 		/* The menu item is already configured, so reconfigure it. */
-		asprintf(&configcommand, DPKG_CONFIGURE_COMMAND " --force-configure %s", p->package);
+		if (asprintf(&configcommand, DPKG_CONFIGURE_COMMAND " --force-configure %s", p->package) == -1) {
+			return 1;
+		}
                 ret = SYSTEM(configcommand);
 		free(configcommand);
 		check_special(p);

Reply to: