From e4bbc5c50b079ff2c6f00c6e2e650502f2ae95f8 Mon Sep 17 00:00:00 2001 From: curt Date: Sat, 30 Jun 2001 02:01:22 +0000 Subject: [PATCH] Fix a potential array under/over run bug. --- SimGear.dsp | 50 ++++++++++++----------------------- simgear/math/interpolater.cxx | 7 ++--- 2 files changed, 21 insertions(+), 36 deletions(-) diff --git a/SimGear.dsp b/SimGear.dsp index 76f944bf..2485ab3b 100644 --- a/SimGear.dsp +++ b/SimGear.dsp @@ -41,7 +41,7 @@ RSC=rc.exe # PROP Intermediate_Dir "Release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /I "\usr\include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "HAVE_CONFIG_H" /FD /c +# ADD CPP /nologo /W3 /GX /O2 /I "." /I ".." /I ".\SimGear" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "HAVE_CONFIG_H" /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -64,7 +64,7 @@ LINK32=link.exe -lib # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /GX /ZI /Od /I "\usr\include" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "HAVE_CONFIG_H" /FR /FD /GZ /c +# ADD CPP /nologo /W3 /GX /ZI /Od /I "." /I ".." /I ".\SimGear" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "HAVE_CONFIG_H" /FR /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe @@ -80,18 +80,6 @@ LINK32=link.exe -lib # Name "SimGear - Win32 Release" # Name "SimGear - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group # Begin Group "Lib_sgbucket" # PROP Default_Filter "" @@ -973,6 +961,21 @@ SOURCE=.\simgear\screen\screen-dump.cxx # End Source File # Begin Source File +SOURCE=.\simgear\screen\tr.cxx + +!IF "$(CFG)" == "SimGear - Win32 Release" + +# PROP Intermediate_Dir "Release\Lib_sgscreen" + +!ELSEIF "$(CFG)" == "SimGear - Win32 Debug" + +# PROP Intermediate_Dir "Debug\Lib_sgscreen" + +!ENDIF + +# End Source File +# Begin Source File + SOURCE=.\simgear\screen\win32-printer.h !IF "$(CFG)" == "SimGear - Win32 Release" @@ -1113,25 +1116,6 @@ SOURCE=.\simgear\sky\stars.cxx !ENDIF -# End Source File -# End Group -# Begin Group "Lib_sgthreads" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\simgear\threads\SGThread.cxx - -!IF "$(CFG)" == "SimGear - Win32 Release" - -# PROP Intermediate_Dir "Release\Lib_sgthreads" - -!ELSEIF "$(CFG)" == "SimGear - Win32 Debug" - -# PROP Intermediate_Dir "Debug\Lib_sgthreads" - -!ENDIF - # End Source File # End Group # Begin Group "Lib_sgtiming" diff --git a/simgear/math/interpolater.cxx b/simgear/math/interpolater.cxx index d3d74350..ccb71d6b 100644 --- a/simgear/math/interpolater.cxx +++ b/simgear/math/interpolater.cxx @@ -83,8 +83,9 @@ double SGInterpTable::interpolate(double x) const int i; double y; - if (size == 0.0) + if (size == 0.0) { return 0.0; + } i = 0; @@ -96,14 +97,14 @@ double SGInterpTable::interpolate(double x) const // printf ("i = %d ", i); - if ( (i == 0) && (x < table[0].ind) ) { + if ( i <= 0 ) { SG_LOG( SG_MATH, SG_DEBUG, "interpolate(): lookup error, x to small = " << x ); return table[0].dep; } // cout << " table[size-1].ind = " << table[size-1].ind << endl; - if ( x > table[size-1].ind ) { + if ( i >= size ) { SG_LOG( SG_MATH, SG_DEBUG, "interpolate(): lookup error, x to big = " << x ); return table[size-1].dep; -- 2.39.5