Commit 52a7d28e authored by Colin Watson's avatar Colin Watson

Handle asprintf failures consistently.

parent 7a1f3959
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
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment