Hello,

I've attached two patches which resolves a possible NULL pointer dereference and
some memory leaks.

Best regards
From 7f8a759896f43aaa1beb54212181c9c0e4fca4fb Mon Sep 17 00:00:00 2001
From: Moritz Lipp <[email protected]>
Date: Sat, 29 Dec 2012 12:18:59 +0100
Subject: [PATCH 1/2] Fix possible NULL pointer dereference

---
 src/libs/export.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/libs/export.c b/src/libs/export.c
index 153f7dd..cde370e 100644
--- a/src/libs/export.c
+++ b/src/libs/export.c
@@ -686,7 +686,11 @@ get_params (dt_lib_module_t *self, int *size)
   int32_t max_height = dt_conf_get_int ("plugins/lighttable/export/height");
   gchar *iccprofile = 
dt_conf_get_string("plugins/lighttable/export/iccprofile");
   gchar *style = dt_conf_get_string("plugins/lighttable/export/style");
-  strncpy(fdata->style, style, 128);
+
+  if (fdata) {
+    strncpy(fdata->style, style, 128);
+  }
+
   if(!iccprofile)
   {
     iccprofile = (char *)g_malloc(1);
-- 
1.8.0.3

From cec4044cbe5bfa529db49ed6e406da5d79934c3d Mon Sep 17 00:00:00 2001
From: Moritz Lipp <[email protected]>
Date: Sat, 29 Dec 2012 12:23:58 +0100
Subject: [PATCH 2/2] Resolve memory leaks

---
 src/libs/export.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/libs/export.c b/src/libs/export.c
index cde370e..60954cc 100644
--- a/src/libs/export.c
+++ b/src/libs/export.c
@@ -92,7 +92,11 @@ export_button_clicked (GtkWidget *widget, gpointer user_data)
   int format_index = dt_conf_get_int ("plugins/lighttable/export/format");
   int storage_index = dt_conf_get_int ("plugins/lighttable/export/storage");
   gboolean high_quality = 
dt_conf_get_bool("plugins/lighttable/export/high_quality_processing");
-  strncpy (style, dt_conf_get_string("plugins/lighttable/export/style"), 128);
+  char* tmp = dt_conf_get_string("plugins/lighttable/export/style");
+  if (tmp) {
+    strncpy (style, tmp, 128);
+    g_free(tmp);
+  }
   dt_control_export(max_width, max_height, format_index, storage_index, 
high_quality, style);
 }
 
@@ -733,6 +737,7 @@ get_params (dt_lib_module_t *self, int *size)
   g_assert(pos == *size);
 
   g_free(iccprofile);
+  g_free(style);
 
   if(fdata) mformat->free_params(mformat, fdata);
   if(sdata) mstorage->free_params(mstorage, sdata);
-- 
1.8.0.3

Attachment: pgpPkUs3CYSgt.pgp
Description: PGP signature

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122912
_______________________________________________
darktable-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/darktable-devel

Reply via email to