Browse Source

Handle asprintf failures consistently.

tags/1.41
Colin Watson 8 years ago
parent
commit
52a7d28eac
2 changed files with 23 additions and 1 deletions
  1. +4
    -0
      debian/changelog
  2. +19
    -1
      main-menu.c

+ 4
- 0
debian/changelog View File

@@ -1,9 +1,13 @@
main-menu (1.41) UNRELEASED; urgency=low

[ Dmitrijs Ledkovs ]
* Set debian source format to '3.0 (native)'.
* Bump debhelper compat level to 9.
* Set Vcs-* to canonical format.

[ Colin Watson ]
* Handle asprintf failures consistently.

-- Dmitrijs Ledkovs <xnox@debian.org> Fri, 07 Jun 2013 00:25:59 +0100

main-menu (1.40) unstable; urgency=low


+ 19
- 1
main-menu.c View File

@@ -16,6 +16,7 @@

#include "main-menu.h"
#include <cdebconf/debconfclient.h>
#include <stdarg.h>
#include <stdlib.h>
#include <search.h>
#include <stdio.h>
@@ -71,6 +72,23 @@ static int debconf_to_pri (char *priority) {
return -1;
}

static char *xasprintf (const char *format, ...)
{
va_list args;
char *result;

va_start(args, format);
if (vasprintf(&result, format, args) < 0) {
if (errno == ENOMEM) {
fputs("Out of memory!\n", stderr);
abort();
}
return NULL;
}

return result;
}

/*
* qsort comparison function (sort by menu item values, fall back to
* lexical sort to resolve ties deterministically).
@@ -542,7 +560,7 @@ static void set_package_title(di_system_package *p) {

if (!p->installer_menu_item)
return;
asprintf(&title, "debian-installer/%s/title", p->p.package);
title = xasprintf("debian-installer/%s/title", p->p.package);
if (debconf_settitle(debconf, title))
di_log(DI_LOG_LEVEL_WARNING, "Unable to set title for %s.", p->p.package);
free(title);


Loading…
Cancel
Save