changeset 3519:63a2e8e00a7b

6999620: [parfait] potential buffer overruns in 2d and awt Reviewed-by: jgodinez, prr
author bae
date Mon, 24 Jan 2011 15:37:57 +0300
parents ade796b84e71
children 74d020ed7f5b bad0ddc6f573
files src/windows/native/sun/java2d/d3d/D3DGraphicsDevice.cpp src/windows/native/sun/windows/awt_Toolkit.cpp
diffstat 2 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/windows/native/sun/java2d/d3d/D3DGraphicsDevice.cpp	Mon Jan 24 15:14:26 2011 +0300
+++ b/src/windows/native/sun/java2d/d3d/D3DGraphicsDevice.cpp	Mon Jan 24 15:37:57 2011 +0300
@@ -396,7 +396,7 @@
     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 @@
     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],
--- a/src/windows/native/sun/windows/awt_Toolkit.cpp	Mon Jan 24 15:14:26 2011 +0300
+++ b/src/windows/native/sun/windows/awt_Toolkit.cpp	Mon Jan 24 15:37:57 2011 +0300
@@ -2491,7 +2491,7 @@
     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 (...) {