printers: Check if printer name is NULL

This was causing a segfault when the user clicks the cancel button
on add new printer dialog (in case when no printers are listed, and no
printers are added).

output from sanitizer:

==22669==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7fe1c7a4d409 bp 0x7ffd179f6410 sp 0x7ffd179f6410 T0)
    #0 0x7fe1c7a4d408 in g_str_hash /home/sadiq/jhbuild/checkout/glib/glib/ghash.c:1882
    #1 0x7fe1c7a4c814 in g_hash_table_lookup_node /home/sadiq/jhbuild/checkout/glib/glib/ghash.c:379
    #2 0x7fe1c7a4c814 in g_hash_table_lookup /home/sadiq/jhbuild/checkout/glib/glib/ghash.c:1153
    #3 0x55cef023a121 in new_printer_dialog_response_cb /home/sadiq/jhbuild/checkout/gnome-control-center/panels/printers/cc-printers-panel.c:914

https://bugzilla.gnome.org/show_bug.cgi?id=783406
This commit is contained in:
Mohammed Sadiq 2017-06-04 20:26:16 +05:30 committed by Marek Kasik
parent 56151c6dee
commit d5110977da

View file

@ -915,6 +915,9 @@ new_printer_dialog_response_cb (PpNewPrinterDialog *dialog,
actualize_printers_list (self);
if (priv->new_printer_name == NULL)
return;
/* Scroll the view to show the newly added printer-entry. */
scrolled_window = GTK_SCROLLED_WINDOW (gtk_builder_get_object (priv->builder,
"scrolled-window"));