From 4bd5cf874a5ff6ea78bac41ff3c4118fb78b83c2 Mon Sep 17 00:00:00 2001 From: bae Date: Mon, 24 Jan 2011 15:37:57 +0300 Subject: [PATCH] 6999620: [parfait] potential buffer overruns in 2d and awt Reviewed-by: jgodinez, prr --- src/windows/native/sun/java2d/d3d/D3DGraphicsDevice.cpp | 4 ++-- src/windows/native/sun/windows/awt_Toolkit.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/windows/native/sun/java2d/d3d/D3DGraphicsDevice.cpp b/src/windows/native/sun/java2d/d3d/D3DGraphicsDevice.cpp index c84e7ea47..efb20c5d3 100644 --- a/src/windows/native/sun/java2d/d3d/D3DGraphicsDevice.cpp +++ b/src/windows/native/sun/java2d/d3d/D3DGraphicsDevice.cpp @@ -396,7 +396,7 @@ Java_sun_java2d_d3d_D3DGraphicsDevice_enumDisplayModesNative UINT adapter; // EnumAdapterModes treats 555 and 565 formats as equivalents static D3DFORMAT formats[] = - { D3DFMT_X8R8G8B8, D3DFMT_R5G6B5 }; + { D3DFMT_X8R8G8B8, D3DFMT_R5G6B5 }; J2dTraceLn(J2D_TRACE_INFO, "D3DGD_enumDisplayModesNative"); @@ -404,7 +404,7 @@ Java_sun_java2d_d3d_D3DGraphicsDevice_enumDisplayModesNative RETURN_IF_NULL(pd3d9 = pMgr->GetD3DObject()); adapter = pMgr->GetAdapterOrdinalForScreen(gdiScreen); - for (formatNum = 0; formatNum < 3; formatNum++) { + for (formatNum = 0; formatNum < (sizeof formats)/(sizeof *formats); formatNum++) { modesCount = pd3d9->GetAdapterModeCount(adapter, formats[formatNum]); for (modeNum = 0; modeNum < modesCount; modeNum++) { if (SUCCEEDED(pd3d9->EnumAdapterModes(adapter, formats[formatNum], diff --git a/src/windows/native/sun/windows/awt_Toolkit.cpp b/src/windows/native/sun/windows/awt_Toolkit.cpp index cf1503981..cab78049f 100644 --- a/src/windows/native/sun/windows/awt_Toolkit.cpp +++ b/src/windows/native/sun/windows/awt_Toolkit.cpp @@ -2491,7 +2491,7 @@ Java_sun_awt_windows_WToolkit_loadSystemColors(JNIEnv *env, jobject self, jint* colorsPtr = NULL; try { colorsPtr = (jint *)env->GetPrimitiveArrayCritical(colors, 0); - for (int i = 0; i < sizeof indexMap && i < colorLen; i++) { + for (int i = 0; i < (sizeof indexMap)/(sizeof *indexMap) && i < colorLen; i++) { colorsPtr[i] = DesktopColor2RGB(indexMap[i]); } } catch (...) { -- GitLab