# HG changeset patch
# User Darren Salt <[EMAIL PROTECTED]>
# Date 1172067129 0
# Node ID 170324915a3f66e7f93fa9d49b091835d5d86820
# Parent b73879b3f7fbac3ae5e6ddcd48bfa9a734b9536b
Fix a HAL lookup memory leak & use NULL if a lookup results in an empty string.
diff -r 170324915a3f66e7f93fa9d49b091835d5d86820 -r
b73879b3f7fbac3ae5e6ddcd48bfa9a734b9536b src/preferences.c
--- a/src/preferences.c Wed Feb 21 14:12:09 2007 +0000
+++ b/src/preferences.c Tue Feb 20 20:51:32 2007 -0500
@@ -325,7 +325,7 @@ get_hal_property (const char *dev, const
}
char *prop = libhal_device_get_property_string (hal, devs[0], prop_tag,
NULL);
- char *ret = strdup (prop ? : "");
+ char *ret = (prop && prop[0]) ? strdup (prop) : NULL;
libhal_free_string (prop);
libhal_free_string_array (devs);
return ret;
@@ -381,10 +381,11 @@ display_hal_device_info (GtkWidget *widg
GtkLabel *info = g_object_get_data (G_OBJECT (widget), "extra");
if (info)
{
- char *content = g_markup_printf_escaped ("<small>%s</small>",
- get_hal_device_info (dev) ? : "");
+ char *hal = get_hal_device_info (dev);
+ char *content = g_markup_printf_escaped ("<small>%s</small>", hal ? : "");
gtk_label_set_markup (info, content);
free (content);
+ free (hal);
}
}
#endif /* WITH_HAL */
@@ -429,7 +430,7 @@ static void file_preview_cb (GtkFileChoo
if (!file)
file = gtk_file_chooser_get_filename (fc);
char *content = get_hal_device_info (file);
- gtk_label_set_text (info, content);
+ gtk_label_set_text (info, content ? : "");
free (content);
g_free (file);
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Xine-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xine-cvslog