diff --git a/common/platform_win32.cpp b/common/platform_win32.cpp index 6ef6043..66fef42 100644 --- a/common/platform_win32.cpp +++ b/common/platform_win32.cpp @@ -162,8 +162,10 @@ bool IsFile(const string& sPath) if (hFind == INVALID_HANDLE_VALUE) return false; - if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + FindClose(hFind); return false; + } return true; } @@ -181,8 +183,10 @@ bool IsDirectory(const string& sPath) if (hFind == INVALID_HANDLE_VALUE) return false; - if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + FindClose(hFind); return true; + } return false; } diff --git a/glfw-2.7.9/lib/tga.c b/glfw-2.7.9/lib/tga.c index 7e0697f..fffd917 100644 --- a/glfw-2.7.9/lib/tga.c +++ b/glfw-2.7.9/lib/tga.c @@ -306,8 +306,7 @@ int _glfwReadTGA( _GLFWstream *s, GLFWimage *img, int flags ) swapy = 0; break; } - if( (swapy && !(flags & GLFW_ORIGIN_UL_BIT)) || - (!swapy && (flags & GLFW_ORIGIN_UL_BIT)) ) + if( swapy != (flags & GLFW_ORIGIN_UL_BIT)) { src = pix; dst = &pix[ (h.height-1)*h.width*bpp ]; diff --git a/math/spline.h b/math/spline.h index 40b93ac..c9cdc56 100644 --- a/math/spline.h +++ b/math/spline.h @@ -5,7 +5,7 @@ struct CubicSpline { vec3 m_points[SPLINE_POINTS]; - vec3 m_coeffs[SPLINE_POINTS-1][4]; + vec3 m_coeffs[SPLINE_POINTS][4]; float m_lengths[SPLINE_POINTS - 1]; // Spline construction, Burden & Faires - Numerical Analysis 9th, algorithm 3.4 @@ -15,7 +15,7 @@ struct CubicSpline vec3 a[SPLINE_POINTS]; for (int i = 1; i <= n - 1; i++) - a[i] = 3 * ((m_points[i + 1] - 2*m_points[i] + m_points[i - 1])); + a[i] = 3 * (m_points[i + 1] - 2*m_points[i] + m_points[i - 1]); float l[SPLINE_POINTS]; float mu[SPLINE_POINTS]; diff --git a/renderer/application.cpp b/renderer/application.cpp index c8c5339..7ec6b63 100644 --- a/renderer/application.cpp +++ b/renderer/application.cpp @@ -98,7 +98,7 @@ bool CApplication::OpenWindow(size_t iWidth, size_t iHeight, bool bFullscreen, b return false; } - glfwSetWindowTitle((char*)L"Math for Game Developers"); + glfwSetWindowTitle("Math for Game Developers"); int iScreenWidth; int iScreenHeight; diff --git a/renderer/image_read.cpp b/renderer/image_read.cpp index d24e106..c7acfd2 100644 --- a/renderer/image_read.cpp +++ b/renderer/image_read.cpp @@ -2967,7 +2967,10 @@ static stbi_uc *tga_load(stbi *s, int *x, int *y, int *comp, int req_comp) skip(s, tga_palette_start ); // load the palette tga_palette = (unsigned char*)malloc( tga_palette_len * tga_palette_bits / 8 ); - if (!tga_palette) return epuc("outofmem", "Out of memory"); + if (!tga_palette) { + free(tga_data); + return epuc("outofmem", "Out of memory"); + } if (!getn(s, tga_palette, tga_palette_len * tga_palette_bits / 8 )) { free(tga_data); free(tga_palette); @@ -3492,6 +3495,8 @@ static stbi_uc *pic_load(stbi *s,int *px,int *py,int *comp,int req_comp) // intermediate buffer is RGBA result = (stbi_uc *) malloc(x*y*4); + if (!result) return epuc("cannot allocate", "cannot allocate memory"); + memset(result, 0xff, x*y*4); if (!pic_load2(s,x,y,comp, result)) {