# HG changeset patch # User mbaesken # Date 1528121481 -7200 # Node ID f8c15a2f2ae99009deb795cfda4fbca68775b547 # Parent 10b8e57899b33ebdb784da93b02eee92566fe740 8204211: windows : handle potential C++ exception in GDIRenderer Reviewed-by: clanger, prr, serb diff -r 10b8e57899b3 -r f8c15a2f2ae9 make/lib/Awt2dLibraries.gmk --- a/make/lib/Awt2dLibraries.gmk Tue Jun 05 14:42:21 2018 -0700 +++ b/make/lib/Awt2dLibraries.gmk Mon Jun 04 16:11:21 2018 +0200 @@ -224,7 +224,7 @@ format-nonliteral parentheses, \ DISABLED_WARNINGS_clang := logical-op-parentheses extern-initializer, \ DISABLED_WARNINGS_solstudio := E_DECLARATION_IN_CODE, \ - DISABLED_WARNINGS_microsoft := 4297 4244 4267 4996, \ + DISABLED_WARNINGS_microsoft := 4244 4267 4996, \ ASFLAGS := $(LIBAWT_ASFLAGS), \ LDFLAGS := $(LDFLAGS_JDKLIB) $(call SET_SHARED_LIBRARY_ORIGIN), \ LDFLAGS_macosx := -L$(INSTALL_LIBRARIES_HERE), \ diff -r 10b8e57899b3 -r f8c15a2f2ae9 src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp --- a/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp Tue Jun 05 14:42:21 2018 -0700 +++ b/src/java.desktop/windows/native/libawt/java2d/windows/GDIRenderer.cpp Mon Jun 04 16:11:21 2018 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -85,7 +85,11 @@ *pNpoints = outpoints; } if (outpoints > POLYTEMPSIZE) { - pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(POINT), outpoints); + try { + pPoints = (POINT *) SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, sizeof(POINT), outpoints); + } catch (const std::bad_alloc&) { + return NULL; + } } BOOL isempty = fixend; for (int i = 0; i < npoints; i++) { diff -r 10b8e57899b3 -r f8c15a2f2ae9 src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp --- a/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp Tue Jun 05 14:42:21 2018 -0700 +++ b/src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp Mon Jun 04 16:11:21 2018 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -873,7 +873,13 @@ int numSizes = ::DeviceCapabilities(printerName, printerPort, DC_PAPERS, NULL, NULL); if (numSizes > 0) { - LPTSTR papers = (LPTSTR)SAFE_SIZE_ARRAY_ALLOC(safe_Malloc, numSizes, sizeof(WORD)); + 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) {