]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
dest.c: Call cupsEnumDests() only if data.name is not NULL (fixes #719)
authorZdenek Dohnal <zdohnal@redhat.com>
Tue, 6 Jun 2023 08:45:37 +0000 (10:45 +0200)
committerZdenek Dohnal <zdohnal@redhat.com>
Tue, 6 Jun 2023 08:45:37 +0000 (10:45 +0200)
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

index 741aae06314c6e819ac3490733555f2e8b8e1767..9a145bca77c086665a0dfa6e52ac189355a4cd49 100644 (file)
@@ -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)
       {