From b3b42fa2a9012807f32f3b098ccf20dea7413657 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Wed, 2 Dec 2015 14:28:38 -0500 Subject: [PATCH] Bug 1229881 - fix off-by-one error in nsPrinterEnumeratorWin::GetPrinterNameList; r=dbaron; a=KWierso --- widget/windows/nsDeviceContextSpecWin.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/widget/windows/nsDeviceContextSpecWin.cpp b/widget/windows/nsDeviceContextSpecWin.cpp index 8bf187619a2..2d265d8d269 100644 --- a/widget/windows/nsDeviceContextSpecWin.cpp +++ b/widget/windows/nsDeviceContextSpecWin.cpp @@ -687,10 +687,9 @@ nsPrinterEnumeratorWin::GetPrinterNameList(nsIStringEnumerator **aPrinterNameLis 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); }