Bug 1229881 - fix off-by-one error in nsPrinterEnumeratorWin::GetPrinterNameList; r=dbaron; a=KWierso
authorNathan Froyd <froydnj@mozilla.com>
Wed, 02 Dec 2015 14:28:38 -0500
changeset 309310 26c0d85b7714ab34d01b4f808eb6de1c00f741aa
parent 309309 f6ac392322b3b06d7112a6db1bf6f8ab1853fdcf
child 309311 880b58f2221ab9b2ed2417bad8e6004b244edf9b
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron, KWierso
bugs1229881
milestone45.0a1
first release with
nightly win32
26c0d85b7714 / 45.0a1 / 20151202115351 / files
nightly win64
26c0d85b7714 / 45.0a1 / 20151202115311 / files
nightly linux32
nightly linux64
nightly mac
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly win32
nightly win64
Bug 1229881 - fix off-by-one error in nsPrinterEnumeratorWin::GetPrinterNameList; r=dbaron; a=KWierso
widget/windows/nsDeviceContextSpecWin.cpp
--- a/widget/windows/nsDeviceContextSpecWin.cpp
+++ b/widget/windows/nsDeviceContextSpecWin.cpp
@@ -682,20 +682,19 @@ nsPrinterEnumeratorWin::GetPrinterNameLi
     return rv;
   }
 
   uint32_t numPrinters = GlobalPrinters::GetInstance()->GetNumPrinters();
   nsTArray<nsString> *printers = new nsTArray<nsString>(numPrinters);
   if (!printers)
     return NS_ERROR_OUT_OF_MEMORY;
 
-  uint32_t printerInx = 0;
   nsString* names = printers->AppendElements(numPrinters);
-  while( printerInx < numPrinters ) {
-    LPWSTR name = GlobalPrinters::GetInstance()->GetItemFromList(printerInx++);
+  for (uint32_t printerInx = 0; printerInx < numPrinters; ++printerInx) {
+    LPWSTR name = GlobalPrinters::GetInstance()->GetItemFromList(printerInx);
     names[printerInx].Assign(name);
   }
 
   return NS_NewAdoptingStringEnumerator(aPrinterNameList, printers);
 }
 
 //----------------------------------------------------------------------------------
 // Display the AdvancedDocumentProperties for the selected Printer