/soc/2013/ankitkv/gobjectification: 8d853ab9225c: Fix crash when...

Ankit Vani a at nevitus.org
Thu Feb 6 12:36:01 EST 2014


Changeset: 8d853ab9225c3e6ab9508bc900038bdf6d9b3191
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2014-02-06 22:49 +0530
Branch:	 gtkdoc-conversion
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/8d853ab9225c

Description:

Fix crash when scanning libgnt

diffstat:

 finch/libgnt/gntkeys.h  |   6 +++---
 finch/libgnt/gntstyle.c |  12 +++++++++++-
 2 files changed, 14 insertions(+), 4 deletions(-)

diffs (56 lines):

diff --git a/finch/libgnt/gntkeys.h b/finch/libgnt/gntkeys.h
--- a/finch/libgnt/gntkeys.h
+++ b/finch/libgnt/gntkeys.h
@@ -42,7 +42,7 @@ extern char *gnt_key_cdown;
 extern char *gnt_key_cleft;
 extern char *gnt_key_cright;
 
-#define SAFE(x)   ((x) ? (x) : "")
+#define SAFE(x)   ((cur_term && (x)) ? (x) : "")
 
 #define GNT_KEY_POPUP   SAFE(key_f16)   /* Apparently */
 
@@ -62,12 +62,12 @@ extern char *gnt_key_cright;
 #define GNT_KEY_HOME   SAFE(key_home)
 #define GNT_KEY_END    SAFE(key_end)
 
-#define GNT_KEY_ENTER  carriage_return
+#define GNT_KEY_ENTER  SAFE(carriage_return)
 
 #define GNT_KEY_BACKSPACE SAFE(key_backspace)
 #define GNT_KEY_DEL    SAFE(key_dc)
 #define GNT_KEY_INS    SAFE(key_ic)
-#define GNT_KEY_BACK_TAB (back_tab ? back_tab : SAFE(key_btab))
+#define GNT_KEY_BACK_TAB ((cur_term && back_tab) ? back_tab : SAFE(key_btab))
 
 #define GNT_KEY_CTRL_A     "\001"
 #define GNT_KEY_CTRL_B     "\002"
diff --git a/finch/libgnt/gntstyle.c b/finch/libgnt/gntstyle.c
--- a/finch/libgnt/gntstyle.c
+++ b/finch/libgnt/gntstyle.c
@@ -48,7 +48,13 @@ const char *gnt_style_get(GntStyle style
 
 char *gnt_style_get_from_name(const char *group, const char *key)
 {
-	const char *prg = g_get_prgname();
+	const char *prg;
+
+	/* gkfile is NULL when run by gtkdoc-scanobj or g-ir-scanner */
+	if (!gkfile)
+		return NULL;
+
+	prg = g_get_prgname();
 	if ((group == NULL || *group == '\0') && prg &&
 			g_key_file_has_group(gkfile, prg))
 		group = prg;
@@ -202,6 +208,10 @@ void gnt_style_read_actions(GType type, 
 	char *name;
 	GError *error = NULL;
 
+	/* gkfile is NULL when run by gtkdoc-scanobj or g-ir-scanner */
+	if (!gkfile)
+		return;
+
 	name = g_strdup_printf("%s::binding", g_type_name(type));
 
 	if (g_key_file_has_group(gkfile, name))



More information about the Commits mailing list