From: Andy Spencer Date: Wed, 5 May 2010 07:40:39 +0000 (+0000) Subject: Fix some possible memory issues in GisHttp X-Git-Tag: v0.4~5 X-Git-Url: http://pileus.org/git/?p=grits;a=commitdiff_plain;h=c4057ccbe87315b3e7c2f1cd321e90e0c67873bb Fix some possible memory issues in GisHttp --- diff --git a/src/data/gis-http.c b/src/data/gis-http.c index 915f648..7f7d03b 100644 --- a/src/data/gis-http.c +++ b/src/data/gis-http.c @@ -245,7 +245,7 @@ GList *gis_http_available(GisHttp *http, /* Add online files if online */ if (index) { - gchar tmp[16]; + gchar tmp[32]; g_snprintf(tmp, sizeof(tmp), ".index.%x", g_random_int()); gchar *path = gis_http_fetch(http, index, tmp, GIS_REFRESH, NULL, NULL); @@ -253,6 +253,8 @@ GList *gis_http_available(GisHttp *http, return files; gchar *html; g_file_get_contents(path, &html, NULL, NULL); + if (!html) + return files; /* Match hrefs by default, this regex is not very accurate */ GRegex *extract_re = g_regex_new( @@ -261,10 +263,12 @@ GList *gis_http_available(GisHttp *http, g_regex_match(extract_re, html, 0, &info); while (g_match_info_matches(info)) { gchar *file = g_match_info_fetch(info, 1); - if (g_regex_match(filter_re, file, 0, NULL)) - files = g_list_prepend(files, file); - else - g_free(file); + if (file) { + if (g_regex_match(filter_re, file, 0, NULL)) + files = g_list_prepend(files, file); + else + g_free(file); + } g_match_info_next(info, NULL); }