[libgda] GdaText: fix memory leaks



commit e2d19e82e5390a95adbdb234fab9ff6cbab66508
Author: Daniel Espinosa <esodan gmail com>
Date:   Mon Apr 22 14:50:31 2019 -0500

    GdaText: fix memory leaks

 libgda/gda-value.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/libgda/gda-value.c b/libgda/gda-value.c
index b33be0cc8..770c1d891 100644
--- a/libgda/gda-value.c
+++ b/libgda/gda-value.c
@@ -409,8 +409,9 @@ gda_text_free (GdaText *text)
 {
        g_return_if_fail (text);
        if (text->str != NULL) {
-               g_free (text);
+               g_free (text->str);
        }
+  g_free (text);
 }
 
 /**
@@ -459,7 +460,7 @@ gda_text_take_string (GdaText *text, gchar *str) {
   if (text->str != NULL) {
     g_free (text->str);
   }
-  text->str = NULL;
+  text->str = str;
 }
 static void
 string_to_text (const GValue *src, GValue *dest)
@@ -495,7 +496,11 @@ static GdaText*
 gda_text_copy (GdaText *boxed)
 {
        GdaText *t = gda_text_new ();
-       t->str = g_strdup (boxed->str);
+  if (boxed->str != NULL) {
+         t->str = g_strdup (boxed->str);
+  } else {
+    t->str = NULL;
+  }
        return t;
 }
 
@@ -1845,7 +1850,7 @@ gda_time_valid (const GdaTime *time)
 GdaTime*
 gda_time_to_timezone (GdaTime *time, GTimeZone *ntz)
 {
-       g_return_if_fail (time);
+       g_return_val_if_fail (time, NULL);
        return (GdaTime*) g_date_time_to_timezone ((GDateTime*) time, ntz);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]