X-Git-Url: https://git.street.me.uk/andy/viking.git/blobdiff_plain/a95be497452fac9dc598e7e6d8500f90a7d3cbef..e2c4a855b70fe77269603d376acc7eb40d56378e:/src/dem.c?ds=sidebyside diff --git a/src/dem.c b/src/dem.c index 66085671..84c257e9 100644 --- a/src/dem.c +++ b/src/dem.c @@ -2,6 +2,7 @@ * viking -- GPS Data and Topo Analyzer, Explorer, and Manager * * Copyright (C) 2003-2008, Evan Battaglia + * Copyright (C) 2007, Quy Tonthat * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,11 +20,21 @@ * */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include +#ifdef HAVE_STRING_H #include +#endif #include +#ifdef HAVE_MATH_H #include +#endif +#ifdef HAVE_STDLIB_H #include +#endif #include #include #include @@ -431,11 +442,14 @@ VikDEM *vik_dem_new_from_file(const gchar *file) /* Header */ f = g_fopen(file, "r"); - if ( !f ) + if ( !f ) { + g_free ( rv ); return NULL; + } buffer[fread(buffer, 1, DEM_BLOCK_SIZE, f)] = '\0'; if ( ! dem_parse_header ( buffer, rv ) ) { g_free ( rv ); + fclose(f); return NULL; } /* TODO: actually use header -- i.e. GET # OF COLUMNS EXPECTED */