From: Zdenek Dohnal Date: Tue, 6 Jun 2023 08:45:37 +0000 (+0200) Subject: dest.c: Call cupsEnumDests() only if data.name is not NULL (fixes #719) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c40c3be43a7a7c4d929ae681bec24bc5ee17c002;p=thirdparty%2Fcups.git dest.c: Call cupsEnumDests() only if data.name is not NULL (fixes #719) Fixes regression created by #452 - in case there is no default destination and `cupsGetNamedDest()` is called to get one (by calling it with argument `name` as NULL), the function crashes. It happens because we try to look for the default printer on the network (where we access `data.name`, which is NULL, in callback), but we never found out the printer's name. Original fix by Emilio Cobos Alvarez. --- diff --git a/cups/dest.c b/cups/dest.c index 741aae0631..9a145bca77 100644 --- a/cups/dest.c +++ b/cups/dest.c @@ -1838,12 +1838,15 @@ cupsGetNamedDest(http_t *http, /* I - Connection to server or @code CUPS_HTT { _cups_namedata_t data; /* Callback data */ - DEBUG_puts("1cupsGetNamedDest: No queue found for printer, looking on network..."); - data.name = dest_name; data.dest = NULL; - cupsEnumDests(0, 1000, NULL, 0, 0, (cups_dest_cb_t)cups_name_cb, &data); + if (data.name) + { + DEBUG_puts("1cupsGetNamedDest: No queue found for printer, looking on network..."); + + cupsEnumDests(0, 1000, NULL, 0, 0, (cups_dest_cb_t)cups_name_cb, &data); + } if (!data.dest) {