[grits] Fix crash when unable to cache http files



commit 016efba1ae80a50c991947fa74723b392dc1cec6
Author: Andy Spencer <andy753421 gmail com>
Date:   Tue Oct 11 06:28:27 2011 +0000

    Fix crash when unable to cache http files

 src/data/grits-http.c |    4 ++++
 src/plugins/elev.c    |    1 +
 2 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/src/data/grits-http.c b/src/data/grits-http.c
index 6075398..3b0c83e 100644
--- a/src/data/grits-http.c
+++ b/src/data/grits-http.c
@@ -164,6 +164,10 @@ gchar *grits_http_fetch(GritsHttp *http, const gchar *uri, const char *local,
 		if (!g_file_test(path, G_FILE_TEST_EXISTS))
 			part = g_strdup_printf("%s.part", path);
 		FILE *fp = fopen_p(part, "ab");
+		if (!fp) {
+			g_warning("GritsHttp: fetch - error opening %s", path);
+			return NULL;
+		}
 		fseek(fp, 0, SEEK_END); // "a" is broken on Windows, twice
 
 		/* Make temp data */
diff --git a/src/plugins/elev.c b/src/plugins/elev.c
index 078fb91..6f03e69 100644
--- a/src/plugins/elev.c
+++ b/src/plugins/elev.c
@@ -204,6 +204,7 @@ static void _load_tile(GritsTile *tile, gpointer _elev)
 
 	struct _LoadTileData *load = g_new0(struct _LoadTileData, 1);
 	load->path = grits_wms_fetch(elev->wms, tile, GRITS_ONCE, NULL, NULL);
+	if (!load->path) return; // Canceled/error
 	g_debug("GritsPluginElev: _load_tile: %s", load->path);
 	load->elev = elev;
 	load->tile = tile;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]