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_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)
{