Fix a memory leak in Litehtml plugin's http loader
authorAndrej Kacian <ticho@claws-mail.org>
Tue, 29 Jan 2019 22:13:51 +0000 (23:13 +0100)
committerAndrej Kacian <ticho@claws-mail.org>
Tue, 12 Feb 2019 18:38:10 +0000 (19:38 +0100)
src/plugins/litehtml_viewer/http.cpp

index bed5638..12e8636 100644 (file)
@@ -73,7 +73,7 @@ GInputStream *http::load_url(const gchar *url, GError **error)
     if (!strncmp(url, "file:///", 8) || g_file_test(url, G_FILE_TEST_EXISTS)) {
        gchar* newurl = g_filename_from_uri(url, NULL, NULL);
        if (g_file_get_contents(newurl ? newurl : url, &content, &len, &_error)) {
-           stream = g_memory_input_stream_new_from_data(content, len, NULL);
+           stream = g_memory_input_stream_new_from_data(content, len, g_free);
        } else {
            debug_print("Got error: %s\n", _error->message);
        }
@@ -88,7 +88,7 @@ GInputStream *http::load_url(const gchar *url, GError **error)
        } else {
            debug_print("Image size: %d\n", data.size);
            stream = g_memory_input_stream_new_from_data(
-               g_memdup(data.memory, data.size), data.size, NULL);
+               g_memdup(data.memory, data.size), data.size, g_free);
            g_free(data.memory);
        }
     }