From: Matthew Fernandez Date: Sat, 2 Jul 2022 15:37:37 +0000 (-0700) Subject: gvpr: exit on allocation failure in 'concat' X-Git-Tag: 5.0.0~5^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=15c9ae9f9a15d2a8428a988431cbf9f02b9ac2c4;p=graphviz gvpr: exit on allocation failure in 'concat' This function gracefully handled allocation failures by returning 0. Except its caller does not check for this and assumes the returned pointer is non-null. --- diff --git a/lib/gvpr/gvpr.c b/lib/gvpr/gvpr.c index ef5e54ade..47c8f5a3d 100644 --- a/lib/gvpr/gvpr.c +++ b/lib/gvpr/gvpr.c @@ -185,11 +185,7 @@ static int parseArgs(char *s, int argc, char ***argv) static char* concat (char* pfx, char* sfx) { - char *sp = malloc(strlen(pfx) + strlen(sfx) + 1); - if (sp == NULL) { - error(ERROR_ERROR, "Out of memory"); - return 0; - } + char *sp = gv_alloc(strlen(pfx) + strlen(sfx) + 1); strcpy(sp, pfx); strcat(sp, sfx); return sp;