Bug 1152921 - Don't send an uninitialized PrintData over IPC when cancelling print dialog (or failing ShowPrintDialog for other reasons). r=mconley

This fixes a crash in debug builds (due to uninitialized booleans) when
canceling a print dialog.
This commit is contained in:
L. David Baron ext:(%2C%20Ben%20Turner%20%3Cbent.mozilla%40gmail.com%3E) 2015-04-16 19:27:01 -07:00
Родитель 37a366fbce
Коммит aa31a08c28
4 изменённых файлов: 22 добавлений и 8 удалений

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

@ -9,12 +9,19 @@ include protocol PPrinting;
namespace mozilla {
namespace embedding {
// A PrintData for success, a failure nsresult for failure.
union PrintDataOrNSResult
{
PrintData;
nsresult;
};
protocol PPrintSettingsDialog
{
manager PPrinting;
child:
__delete__(nsresult rv, PrintData data);
__delete__(PrintDataOrNSResult result);
};
} // namespace embedding

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

@ -21,11 +21,15 @@ PrintSettingsDialogChild::~PrintSettingsDialogChild()
}
bool
PrintSettingsDialogChild::Recv__delete__(const nsresult& aResult,
const PrintData& aData)
PrintSettingsDialogChild::Recv__delete__(const PrintDataOrNSResult& aData)
{
mResult = aResult;
mData = aData;
if (aData.type() == PrintDataOrNSResult::Tnsresult) {
mResult = aData.get_nsresult();
MOZ_ASSERT(NS_FAILED(mResult), "expected a failure result");
} else {
mResult = NS_OK;
mData = aData.get_PrintData();
}
mReturned = true;
return true;
}

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

@ -16,8 +16,7 @@ class PrintSettingsDialogChild final : public PPrintSettingsDialogChild
public:
MOZ_IMPLICIT PrintSettingsDialogChild();
virtual bool Recv__delete__(const nsresult& aResult,
const PrintData& aData) override;
virtual bool Recv__delete__(const PrintDataOrNSResult& aData) override;
bool returned() { return mReturned; };
nsresult result() { return mResult; };

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

@ -117,7 +117,11 @@ PrintingParent::RecvShowPrintDialog(PPrintSettingsDialogParent* aDialog,
// to hear about the print settings. We return the results
// with an async message which frees the child process from
// its nested event loop.
mozilla::unused << aDialog->Send__delete__(aDialog, rv, resultData);
if (NS_FAILED(rv)) {
mozilla::unused << aDialog->Send__delete__(aDialog, rv);
} else {
mozilla::unused << aDialog->Send__delete__(aDialog, resultData);
}
return true;
}