Bug 1870540: Fix nsPrintSettingsGTK assignment operator to null-check a member before increasing its reference count. r=stransky

This change shouldn't change behavior for most users, since
g_object_ref(nullptr) fails gracefully.  But in certain configurations,
e.g. with environmental variable G_DEBUG=fatal-criticals, its graceful-failure
will also trigger a diagnostic warning or abort, which is worth avoiding.
Hence, this patch.

Differential Revision: https://phabricator.services.mozilla.com/D196690
This commit is contained in:
Daniel Holbert 2023-12-18 15:00:53 +00:00
parent 2204ff8785
commit 23fdc24deb

View file

@ -96,7 +96,11 @@ nsPrintSettingsGTK& nsPrintSettingsGTK::operator=(
mPrintSettings = gtk_print_settings_copy(rhs.mPrintSettings);
if (mGTKPrinter) g_object_unref(mGTKPrinter);
mGTKPrinter = (GtkPrinter*)g_object_ref(rhs.mGTKPrinter);
if (rhs.mGTKPrinter) {
g_object_ref(rhs.mGTKPrinter);
}
mGTKPrinter = rhs.mGTKPrinter;
return *this;
}