From ed53220b4faccfd184b212bb89a075bfa53ea886 Mon Sep 17 00:00:00 2001 From: Michael Esemplare Date: Mon, 7 Oct 2013 09:29:10 -0700 Subject: Fix Bug 365: Bug on javax.media.opengl.glu.GLU.gluBuild2DMipmaps Fixed convolution window widths for single column scaling. --- .../jogamp/opengl/glu/mipmap/ScaleInternal.java | 77 ++++++++++++++++++---- 1 file changed, 63 insertions(+), 14 deletions(-) (limited to 'src/jogl/classes/jogamp/opengl/glu') diff --git a/src/jogl/classes/jogamp/opengl/glu/mipmap/ScaleInternal.java b/src/jogl/classes/jogamp/opengl/glu/mipmap/ScaleInternal.java index 5f086ceff..9c95ae304 100644 --- a/src/jogl/classes/jogamp/opengl/glu/mipmap/ScaleInternal.java +++ b/src/jogl/classes/jogamp/opengl/glu/mipmap/ScaleInternal.java @@ -195,8 +195,15 @@ public class ScaleInternal { highy_int = heightin - 1; lowx_int = 0; lowx_float = 0.0f; - highx_int = convx_int; - highx_float = convx_float; + // If we have a single column, fix the max width values + // to prevent buffer overflow + if (widthin == 1 && widthout == 1) { + highx_int = 0; + highx_float = 0.0f; + } else { + highx_int = convx_int; + highx_float = convx_float; + } for( j = 0; j < widthout; j++ ) { @@ -414,8 +421,15 @@ public class ScaleInternal { highy_int = heightin - 1; lowx_int = 0; lowx_float = 0.0f; - highx_int = convx_int; - highx_float = convx_float; + // If we have a single column, fix the max width values + // to prevent buffer overflow + if (widthin == 1 && widthout == 1) { + highx_int = 0; + highx_float = 0.0f; + } else { + highx_int = convx_int; + highx_float = convx_float; + } for( j = 0; j < widthout; j++ ) { @@ -632,8 +646,15 @@ public class ScaleInternal { highy_int = heightin - 1; lowx_int = 0; lowx_float = 0.0f; - highx_int = convx_int; - highx_float = convx_float; + // If we have a single column, fix the max width values + // to prevent buffer overflow + if (widthin == 1 && widthout == 1) { + highx_int = 0; + highx_float = 0.0f; + } else { + highx_int = convx_int; + highx_float = convx_float; + } for( j = 0; j < widthout; j++ ) { @@ -915,8 +936,15 @@ public class ScaleInternal { highy_int = heightin - 1; lowx_int = 0; lowx_float = 0.0f; - highx_int = convx_int; - highx_float = convx_float; + // If we have a single column, fix the max width values + // to prevent buffer overflow + if (widthin == 1 && widthout == 1) { + highx_int = 0; + highx_float = 0.0f; + } else { + highx_int = convx_int; + highx_float = convx_float; + } for( j = 0; j < widthout; j++ ) { @@ -1210,8 +1238,15 @@ public class ScaleInternal { highy_int = heightin - 1; lowx_int = 0; lowx_float = 0.0f; - highx_int = convx_int; - highx_float = convx_float; + // If we have a single column, fix the max width values + // to prevent buffer overflow + if (widthin == 1 && widthout == 1) { + highx_int = 0; + highx_float = 0.0f; + } else { + highx_int = convx_int; + highx_float = convx_float; + } for( j = 0; j < widthout; j++ ) { @@ -1500,8 +1535,15 @@ public class ScaleInternal { highy_int = heightin - 1; lowx_int = 0; lowx_float = 0.0f; - highx_int = convx_int; - highx_float = convx_float; + // If we have a single column, fix the max width values + // to prevent buffer overflow + if (widthin == 1 && widthout == 1) { + highx_int = 0; + highx_float = 0.0f; + } else { + highx_int = convx_int; + highx_float = convx_float; + } for( j = 0; j < widthout; j++ ) { @@ -1797,8 +1839,15 @@ public class ScaleInternal { highy_int = heightin - 1; lowx_int = 0; lowx_float = 0.0f; - highx_int = convx_int; - highx_float = convx_float; + // If we have a single column, fix the max width values + // to prevent buffer overflow + if (widthin == 1 && widthout == 1) { + highx_int = 0; + highx_float = 0.0f; + } else { + highx_int = convx_int; + highx_float = convx_float; + } for( j = 0; j < widthout; j++ ) { -- cgit v1.2.3