From c40c3be43a7a7c4d929ae681bec24bc5ee17c002 Mon Sep 17 00:00:00 2001 From: Zdenek Dohnal Date: Tue, 6 Jun 2023 10:45:37 +0200 Subject: [PATCH] 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. --- cups/dest.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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) { -- 2.47.2