diff --git a/ppd/ppd-collection.cxx b/ppd/ppd-collection.cxx index 74854111..3125fa27 100644 --- a/ppd/ppd-collection.cxx +++ b/ppd/ppd-collection.cxx @@ -586,7 +586,14 @@ ppdCollectionListPPDs( cupsArrayAdd(result, strdup(ppd->record.make)); else { - newppd = (ppd_info_t *)malloc(sizeof(ppd_info_t)); + if ((newppd = (ppd_info_t *)malloc(sizeof(ppd_info_t))) == NULL) + { + if (log) log(ld, CF_LOGLEVEL_ERROR, + "libppd: [PPD Collections] Ran out of memory copying " + "PPD %s!", + ppd->record.name); + break; + } memcpy(newppd, ppd, sizeof(ppd_info_t)); cupsArrayAdd(result, newppd); } @@ -2089,7 +2096,14 @@ load_ppds(const char *d, // I - Actual directory // Nope, add it to the Inodes array and continue... // - dinfoptr = (struct stat *)malloc(sizeof(struct stat)); + if ((dinfoptr = (struct stat *)malloc(sizeof(struct stat))) == NULL) + { + if (log) log(ld, CF_LOGLEVEL_ERROR, + "libppd: [PPD Collections] Ran out of memory recording " + "\"%s\" for loop detection!", + d); + return (0); + } memcpy(dinfoptr, &dinfo, sizeof(struct stat)); cupsArrayAdd(ppdlist->Inodes, dinfoptr);