From 48ff5e55d254e905555a616b2291a89230b104ea Mon Sep 17 00:00:00 2001 From: Per Inge Mathisen Date: Fri, 18 Feb 2011 15:54:39 +0100 Subject: [PATCH] Fix 2 cpp check warnings reported by pabs3. --- lib/ivis_opengl/imdload.cpp | 15 +++++++-------- lib/ivis_opengl/png_util.cpp | 1 + 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/ivis_opengl/imdload.cpp b/lib/ivis_opengl/imdload.cpp index 1f0945968..fd923bb17 100644 --- a/lib/ivis_opengl/imdload.cpp +++ b/lib/ivis_opengl/imdload.cpp @@ -503,7 +503,14 @@ static iIMDShape *_imd_load_level(const char **ppFileData, const char *FileDataE iIMDShape *s = NULL; if (nlevels == 0) + { return NULL; + } + + // Load optional MATERIALS directive + pTmp = pFileData; // remember position + i = sscanf(pFileData, "%255s %n", buffer, &cnt); + ASSERT_OR_RETURN(NULL, i == 1, "Bad directive following LEVEL"); s = (iIMDShape*)malloc(sizeof(iIMDShape)); if (s == NULL) @@ -512,26 +519,18 @@ static iIMDShape *_imd_load_level(const char **ppFileData, const char *FileDataE debug(LOG_ERROR, "_imd_load_level: Memory allocation error"); return NULL; } - s->flags = 0; s->nconnectors = 0; // Default number of connectors must be 0 s->npoints = 0; s->npolys = 0; - s->points = NULL; s->polys = NULL; s->connectors = NULL; s->next = NULL; - s->shadowEdgeList = NULL; s->nShadowEdges = 0; s->texpage = iV_TEX_INVALID; s->tcmaskpage = iV_TEX_INVALID; - - // Load optional MATERIALS directive - pTmp = pFileData; // remember position - i = sscanf(pFileData, "%255s %n", buffer, &cnt); - ASSERT_OR_RETURN(NULL, i == 1, "Bad directive following LEVEL"); memset(s->material, 0, sizeof(s->material)); s->material[LIGHT_AMBIENT][3] = 1.0f; s->material[LIGHT_DIFFUSE][3] = 1.0f; diff --git a/lib/ivis_opengl/png_util.cpp b/lib/ivis_opengl/png_util.cpp index 831ea2e44..ebdcdf380 100644 --- a/lib/ivis_opengl/png_util.cpp +++ b/lib/ivis_opengl/png_util.cpp @@ -323,6 +323,7 @@ void iV_saveImage_JPEG(const char *fileName, const iV_Image *image) if (jpeg == NULL) { debug(LOG_ERROR, "pie_JPEGSaveFile: Couldn't allocate memory\n"); + free(buffer); return; }