Fix a potential array under/over run bug.

This commit is contained in:
curt
2001-06-30 02:01:22 +00:00
parent b481ccd749
commit e4bbc5c50b
2 changed files with 21 additions and 36 deletions

View File

@@ -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"

View File

@@ -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;