[Commits] [SCM] claws branch, litehtml, updated. 3.17.3-96-g903c44e

miras at claws-mail.org miras at claws-mail.org
Sun Jan 27 12:32:41 CET 2019


The branch, litehtml has been updated
       via  903c44e366c83ea856ce7e7dd45aa61059d0d358 (commit)
       via  d96c2193ff03c94a02453daf47400db74ac8894c (commit)
       via  370d1ed483ac2c82345822c7c6c07779762198e6 (commit)
       via  a09c703495e9e7e535051a24791c7dbb27877ff9 (commit)
       via  d92a8ab188823edb95760c128af3bfc1b7173263 (commit)
       via  01385d77909ebad7637e69fbab6abbfa4bd34448 (commit)
      from  53a7361bf4830ae22e0872daf1ecb23e6f82d322 (commit)

Summary of changes:
 src/common/pkcs5_pbkdf2.c                 |   24 +++++++++++++-----------
 src/common/utils.c                        |    7 +++----
 src/plugins/litehtml_viewer/http.cpp      |   20 +++++++++++---------
 src/plugins/litehtml_viewer/http.h        |    3 ++-
 src/plugins/litehtml_viewer/lh_widget.cpp |   11 ++++++-----
 src/plugins/litehtml_viewer/lh_widget.h   |    3 ---
 src/plugins/vcalendar/vcal_folder.c       |    9 ++++++---
 7 files changed, 41 insertions(+), 36 deletions(-)


- Log -----------------------------------------------------------------
commit 903c44e366c83ea856ce7e7dd45aa61059d0d358
Merge: d96c219 370d1ed
Author: Michael Rasmussen <mir at datanom.net>
Date:   Sun Jan 27 12:25:41 2019 +0100

    Merge branch 'master' into litehtml


commit d96c2193ff03c94a02453daf47400db74ac8894c
Author: Michael Rasmussen <mir at datanom.net>
Date:   Sun Jan 27 12:21:37 2019 +0100

    Refactor http class to prevent memory leak
    
    Signed-off-by: Michael Rasmussen <mir at datanom.net>

diff --git a/src/plugins/litehtml_viewer/http.cpp b/src/plugins/litehtml_viewer/http.cpp
index 7472bd7..bed5638 100644
--- a/src/plugins/litehtml_viewer/http.cpp
+++ b/src/plugins/litehtml_viewer/http.cpp
@@ -22,11 +22,13 @@ http::http()
     curl_easy_setopt(curl, CURLOPT_TCP_KEEPIDLE, 120L);
     curl_easy_setopt(curl, CURLOPT_TCP_KEEPINTVL, 60L);
     curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, http::curl_write_data);
+    stream = NULL;
 }
 
 http::~http()
 {
     curl_easy_cleanup(curl);
+    destroy_giostream();
 }
 
 size_t http::curl_write_data(char* ptr, size_t size, size_t nmemb, void* data_ptr) {
@@ -48,12 +50,12 @@ size_t http::curl_write_data(char* ptr, size_t size, size_t nmemb, void* data_pt
     return realsize;
 }
 
-void http::destroy_giostream(gpointer data) {
-    GInputStream* gio;
-    if (data) {
-	gio = G_INPUT_STREAM(data);
-	g_input_stream_close(gio, NULL, NULL);
-	gio = NULL;
+void http::destroy_giostream() {
+    debug_print("destroy_giostream called.\n");
+    if (stream) {
+	debug_print("Freeing input_stream\n");
+	g_input_stream_close(stream, NULL, NULL);
+	g_object_unref(stream);
     }
 }
 
@@ -63,7 +65,6 @@ GInputStream *http::load_url(const gchar *url, GError **error)
     CURLcode res = CURLE_OK;
     gsize len;
     gchar* content;
-    GInputStream* stream = NULL;
     struct Data data;
 
     data.memory = (char *) g_malloc(1);
@@ -72,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, http::destroy_giostream);
+	    stream = g_memory_input_stream_new_from_data(content, len, NULL);
 	} else {
 	    debug_print("Got error: %s\n", _error->message);
 	}
@@ -86,7 +87,8 @@ GInputStream *http::load_url(const gchar *url, GError **error)
 	    _error = g_error_new_literal(G_FILE_ERROR, res, curl_easy_strerror(res));
 	} 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, http::destroy_giostream);
+	    stream = g_memory_input_stream_new_from_data(
+		g_memdup(data.memory, data.size), data.size, NULL);
 	    g_free(data.memory);
 	}
     }
diff --git a/src/plugins/litehtml_viewer/http.h b/src/plugins/litehtml_viewer/http.h
index c8c3bee..d0ae4c8 100644
--- a/src/plugins/litehtml_viewer/http.h
+++ b/src/plugins/litehtml_viewer/http.h
@@ -11,6 +11,7 @@
 class http
 {
     CURL*           curl;
+    GInputStream*   stream;
 
 public:
     http();
@@ -20,7 +21,7 @@ public:
 
 private:
     static size_t curl_write_data(char* ptr, size_t size, size_t nmemb, void* data_ptr);
-    static void destroy_giostream(gpointer data);
+    void destroy_giostream();
 };
 
 
diff --git a/src/plugins/litehtml_viewer/lh_widget.cpp b/src/plugins/litehtml_viewer/lh_widget.cpp
index c561e9c..8db070c 100644
--- a/src/plugins/litehtml_viewer/lh_widget.cpp
+++ b/src/plugins/litehtml_viewer/lh_widget.cpp
@@ -92,7 +92,6 @@ lh_widget::lh_widget()
 			        GDK_BUTTON_RELEASE_MASK
 			      | GDK_BUTTON_PRESS_MASK
 			      | GDK_POINTER_MOTION_MASK);
-
 }
 
 lh_widget::~lh_widget()
@@ -153,6 +152,7 @@ GdkPixbuf *lh_widget::get_image(const litehtml::tchar_t* url, bool redraw_on_rea
 {
 	GError *error = NULL;
 	GdkPixbuf *pixbuf = NULL;
+	http* http_loader = NULL;
 
 	if (!lh_prefs_get()->enable_remote_content) {
 		debug_print("blocking download of image from '%s'\n", url);
@@ -164,8 +164,8 @@ GdkPixbuf *lh_widget::get_image(const litehtml::tchar_t* url, bool redraw_on_rea
         lh_widget_statusbar_push(msg);
 	g_free(msg);
 	
-	http http_loader;
-	GInputStream *image = http_loader.load_url(url, &error);
+	http_loader = new http();
+	GInputStream *image = http_loader->load_url(url, &error);
     
 	if (error || !image) {
 	    if (error) {
@@ -178,11 +178,9 @@ GdkPixbuf *lh_widget::get_image(const litehtml::tchar_t* url, bool redraw_on_rea
 	pixbuf = gdk_pixbuf_new_from_stream(image, NULL, &error);
 	if (error) {
 	    g_warning("lh_widget::get_image: Could not create pixbuf %s", error->message);
-	    //g_object_unref(pixbuf);
 	    pixbuf = NULL;
 	    g_clear_error(&error);
 	}
-	g_input_stream_close(image, NULL, NULL);
 
 /*	if (redraw_on_ready) {
 		redraw();
@@ -190,6 +188,9 @@ GdkPixbuf *lh_widget::get_image(const litehtml::tchar_t* url, bool redraw_on_rea
 
 statusbar_pop:
 	lh_widget_statusbar_pop();
+	if (http_loader) {
+		delete http_loader;
+	}
 	
 	return pixbuf;
 }

commit 01385d77909ebad7637e69fbab6abbfa4bd34448
Author: Michael Rasmussen <mir at datanom.net>
Date:   Sun Jan 27 01:11:24 2019 +0100

    Remove unused stuff
    
    Signed-off-by: Michael Rasmussen <mir at datanom.net>

diff --git a/src/plugins/litehtml_viewer/lh_widget.h b/src/plugins/litehtml_viewer/lh_widget.h
index ed56f7d..daffcac 100644
--- a/src/plugins/litehtml_viewer/lh_widget.h
+++ b/src/plugins/litehtml_viewer/lh_widget.h
@@ -4,8 +4,6 @@
 
 #include "container_linux.h"
 
-#define HTTP_GET_TIMEOUT 5L
-
 class lh_widget : public container_linux
 {
 	public:
@@ -36,7 +34,6 @@ class lh_widget : public container_linux
 
 	private:
 		void paint_white();
-		GInputStream *load_url(const gchar *url, GError **error);
 
 		gint m_rendered_width;
 		GtkWidget *m_drawing_area;

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list