pidgin: 6b6dc5c2: Add some NULL checks. Now it should not ...

qulogic at pidgin.im qulogic at pidgin.im
Wed Sep 21 03:07:24 EDT 2011


----------------------------------------------------------------------
Revision: 6b6dc5c26a509d3f927a21d89147b6abad5684d8
Parent:   6d8f1be808eb3c2766f72abdbbcc07b914164f01
Author:   qulogic at pidgin.im
Date:     09/21/11 03:01:58
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/6b6dc5c26a509d3f927a21d89147b6abad5684d8

Changelog: 

Add some NULL checks. Now it should not crash even if you don't have
the default theme installed (which you won't since it's not even
written yet!) You just won't see anything...

Changes against parent 6d8f1be808eb3c2766f72abdbbcc07b914164f01

  patched  pidgin/gtkconv-theme.c
  patched  pidgin/gtkconv.c

-------------- next part --------------
============================================================
--- pidgin/gtkconv.c	a6cde1c44fdb25c59b0c89dab30be32d16a3f7e9
+++ pidgin/gtkconv.c	afddf7eadbf36f4dd5b692714d9b9883c714bdb6
@@ -5031,6 +5031,9 @@ replace_template_tokens(PidginConvTheme 
 	char *path;
 
 	text = pidgin_conversation_theme_get_template(theme, PIDGIN_CONVERSATION_THEME_TEMPLATE_MAIN);
+	if (text == NULL)
+		return NULL;
+
 	ms = g_strsplit(text, "%@", 6);
 	if (ms[0] == NULL || ms[1] == NULL || ms[2] == NULL || ms[3] == NULL || ms[4] == NULL || ms[5] == NULL) {
 		g_strfreev(ms);
@@ -5977,10 +5980,14 @@ replace_message_tokens(
 	PurpleMessageFlags flags,
 	time_t mtime)
 {
-	GString *str = g_string_new(NULL);
+	GString *str;
 	const char *cur = text;
 	const char *prev = cur;
 
+	if (text == NULL)
+		return g_strdup("");
+
+	str = g_string_new(NULL);
 	while ((cur = strchr(cur, '%'))) {
 		const char *replace = NULL;
 		const char *fin = NULL;
============================================================
--- pidgin/gtkconv-theme.c	334f181aa885e5d714d1684c8768bd3479415a65
+++ pidgin/gtkconv-theme.c	42ee94e4e33881a9e417b1111f0ac568f0093a00
@@ -498,6 +498,9 @@ pidgin_conversation_theme_get_info(const
 pidgin_conversation_theme_get_info(const PidginConvTheme *theme)
 {
 	PidginConvThemePrivate *priv;
+
+	g_return_val_if_fail(theme != NULL, NULL);
+
 	priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
 	return priv->info;
 }
@@ -506,6 +509,9 @@ pidgin_conversation_theme_set_info(Pidgi
 pidgin_conversation_theme_set_info(PidginConvTheme *theme, GHashTable *info)
 {
 	PidginConvThemePrivate *priv;
+
+	g_return_if_fail(theme != NULL);
+
 	priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
 
 	if (priv->info)
@@ -518,6 +524,9 @@ pidgin_conversation_theme_lookup(PidginC
 pidgin_conversation_theme_lookup(PidginConvTheme *theme, const char *key, gboolean specific)
 {
 	PidginConvThemePrivate *priv;
+
+	g_return_val_if_fail(theme != NULL, NULL);
+
 	priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
 
 	return get_key(priv, key, specific);
@@ -530,6 +539,8 @@ pidgin_conversation_theme_get_template(P
 	const char *dir;
 	const char *html;
 
+	g_return_val_if_fail(theme != NULL, NULL);
+
 	priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
 	dir = purple_theme_get_dir(PURPLE_THEME(theme));
 
@@ -593,6 +604,10 @@ pidgin_conversation_theme_add_variant(Pi
 pidgin_conversation_theme_add_variant(PidginConvTheme *theme, char *variant)
 {
 	PidginConvThemePrivate *priv;
+
+	g_return_if_fail(theme != NULL);
+	g_return_if_fail(variant != NULL);
+
 	priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
 
 	priv->variants = g_list_prepend(priv->variants, variant);
@@ -602,6 +617,9 @@ pidgin_conversation_theme_get_variant(Pi
 pidgin_conversation_theme_get_variant(PidginConvTheme *theme)
 {
 	PidginConvThemePrivate *priv;
+
+	g_return_val_if_fail(theme != NULL, NULL);
+
 	priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
 
 	return g_strdup(priv->variant);
@@ -613,6 +631,10 @@ pidgin_conversation_theme_set_variant(Pi
 	PidginConvThemePrivate *priv;
 	const GValue *val;
 	char *prefname;
+
+	g_return_if_fail(theme != NULL);
+	g_return_if_fail(variant != NULL);
+
 	priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
 
 	g_free(priv->variant);
@@ -629,6 +651,9 @@ pidgin_conversation_theme_get_variants(P
 pidgin_conversation_theme_get_variants(PidginConvTheme *theme)
 {
 	PidginConvThemePrivate *priv;
+
+	g_return_val_if_fail(theme != NULL, NULL);
+
 	priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
 
 	return priv->variants;
@@ -640,6 +665,8 @@ pidgin_conversation_theme_get_template_p
 	const char *dir;
 	char *filename;
 
+	g_return_val_if_fail(theme != NULL, NULL);
+
 	dir = purple_theme_get_dir(PURPLE_THEME(theme));
 	filename = g_build_filename(dir, "Contents", "Resources", "Template.html", NULL);
 
@@ -657,6 +684,8 @@ pidgin_conversation_theme_get_css_path(P
 	PidginConvThemePrivate *priv;
 	const char *dir;
 
+	g_return_val_if_fail(theme != NULL, NULL);
+
 	priv = PIDGIN_CONV_THEME_GET_PRIVATE(theme);
 
 	dir = purple_theme_get_dir(PURPLE_THEME(theme));


More information about the Commits mailing list