< prev index next >

src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp

Print this page
rev 50364 : 8204211: windows : handle potential C++ exception in GDIRenderer

*** 871,881 **** SAVE_CONTROLWORD int numSizes = ::DeviceCapabilities(printerName, printerPort, DC_PAPERS, NULL, NULL); if (numSizes > 0) { ! LPTSTR papers = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, numSizes, sizeof(WORD)); if (papers != NULL && ::DeviceCapabilities(printerName, printerPort, DC_PAPERS, papers, NULL) != -1) { int present = 0; for (int i=0;i<numSizes;i++) { --- 871,887 ---- SAVE_CONTROLWORD int numSizes = ::DeviceCapabilities(printerName, printerPort, DC_PAPERS, NULL, NULL); if (numSizes > 0) { ! LPTSTR papers; ! try { ! papers = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, numSizes, sizeof(WORD)); ! } catch (const std::bad_alloc&) { ! papers = NULL; ! } ! if (papers != NULL && ::DeviceCapabilities(printerName, printerPort, DC_PAPERS, papers, NULL) != -1) { int present = 0; for (int i=0;i<numSizes;i++) {
< prev index next >