Do not leak memory and unref the result if valid
authorRicardo Mones <ricardo@mones.org>
Thu, 2 May 2013 08:23:38 +0000 (10:23 +0200)
committerRicardo Mones <ricardo@mones.org>
Thu, 2 May 2013 08:23:38 +0000 (10:23 +0200)
src/news.c

index 1102b4bcf454911cfda48b9909fc840e189dbb50..3717569472e995177d01cb6dd8ae830812353952 100644 (file)
@@ -799,8 +799,11 @@ static gint news_get_article(Folder *folder, gint num, gchar *filename)
        r = nntp_threaded_article(folder, num, &result, &len);
        
        if (r == NEWSNNTP_NO_ERROR) {
-               if (str_write_to_file(result, filename) < 0)
+               if (str_write_to_file(result, filename) < 0) {
+                       mmap_string_unref(result);
                        return -1;
+               }
+               mmap_string_unref(result);
        }
        
        return r;