Bug 452438 - Null-check stored printer-name string before passing it to nsTSubstring::Equals(), to avoid triggering an assertion. r+sr=roc

This commit is contained in:
Daniel Holbert 2008-08-28 12:01:26 -07:00
Родитель 3475ec9eab
Коммит 7ee9f18094
1 изменённых файлов: 6 добавлений и 1 удалений

Просмотреть файл

@ -491,7 +491,12 @@ nsPrintSettingsGTK::SetPrinterName(const PRUnichar * aPrinter)
gtkPrinter.Cut(0, strlen("CUPS/"));
}
if (!gtkPrinter.Equals(gtk_print_settings_get_printer(mPrintSettings))) {
// Give mPrintSettings the passed-in printer name if either...
// - it has no printer name stored yet
// - it has an existing printer name that's different from
// the name passed to this function.
const char* oldPrinterName = gtk_print_settings_get_printer(mPrintSettings);
if (!oldPrinterName || !gtkPrinter.Equals(oldPrinterName)) {
mIsInitedFromPrinter = PR_FALSE;
mIsInitedFromPrefs = PR_FALSE;
gtk_print_settings_set_printer(mPrintSettings, gtkPrinter.get());