Last Comment Bug 707864 - select to print with no printers installed results in app crash
: select to print with no printers installed results in app crash
Status: UNCONFIRMED
:
Product: Core
Classification: Components
Component: Printing: Setup (show other bugs)
: unspecified
: x86 OS/2
: -- normal with 1 vote (vote)
: ---
Assigned To: Nobody; OK to take it and work on it
:
Mentors:
: 377497 (view as bug list)
Depends on:
Blocks: 415522
  Show dependency treegraph
 
Reported: 2011-12-05 19:01 PST by Erdmann
Modified: 2012-07-05 12:33 PDT (History)
6 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Stack trace (trap log) (115.06 KB, text/plain)
2011-12-05 19:27 PST, Erdmann
no flags Details

Description Erdmann 2011-12-05 19:01:54 PST
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)

Steps to reproduce:

press print button (with no printer installed)


Actual results:

application crash


Expected results:

Error is in mozilla/widget/src/os2/nsDeviceContextSpecOS2.cpp#653 as a check is missing on if any printers are installed at all (derefencing "Elements" of a nsTArray is not allowed if array is empty).
I suggest:

void GlobalPrinters::GetDefaultPrinterName(PRUnichar*& aDefaultPrinterName)
...
nsAutoChar16Buffer printerName;
PRInt32 printerNameLength;
MultiByteToWideChar(0, printer, strlen(printer), printerName,
      printerNameLength);
if (!printerName.IsEmpty())
{
    aDefaultPrinterName = ToNewUnicode(nsDependentString(printerName.Elements()));
}
...

Same holds true (analogous) for this member function:
nsresult GlobalPrinters::InitializeGlobalPrinters ()

}
Comment 1 Erdmann 2011-12-05 19:04:19 PST
Forgot:
if (!printerName.IsEmpty())
{
    aDefaultPrinterName = ToNewUnicode(nsDependentString(printerName.Elements()));
}
else
{
    aDefaultPrinterName = NULL;
}
Comment 2 Erdmann 2011-12-05 19:07:56 PST
or rather (judging from the Windows implementation):
if (!printerName.IsEmpty())
{
    aDefaultPrinterName = ToNewUnicode(nsDependentString(printerName.Elements()));
}
else
{
    aDefaultPrinterName = "";
}
Comment 3 Erdmann 2011-12-05 19:27:05 PST
Created attachment 579198 [details]
Stack trace (trap log)
Comment 4 Robert Kaiser (not working on stability any more) 2012-07-05 12:33:15 PDT
*** Bug 377497 has been marked as a duplicate of this bug. ***

Note You need to log in before you can comment on or make changes to this bug.