BUG/MINOR: systemd: check return value of calloc()

The wrapper is not the best reliable thing in the universe, so start
by adding at least the minimum expected controls :-/

To be backported to 1.5 and 1.6.
This commit is contained in:
Willy Tarreau 2016-10-25 17:05:56 +02:00
parent 4351ea61fb
commit 3747ea07ce

View File

@ -77,11 +77,17 @@ static void spawn_haproxy(char **pid_strv, int nb_pid)
pid = fork();
if (!pid) {
/* 3 for "haproxy -Ds -sf" */
char **argv = calloc(4 + main_argc + nb_pid + 1, sizeof(char *));
char **argv;
int i;
int argno = 0;
/* 3 for "haproxy -Ds -sf" */
argv = calloc(4 + main_argc + nb_pid + 1, sizeof(char *));
if (!argv) {
fprintf(stderr, SD_NOTICE "haproxy-systemd-wrapper: failed to calloc(), please try again later.\n");
exit(1);
}
reset_signal_handler();
locate_haproxy(haproxy_bin, 512);
argv[argno++] = haproxy_bin;