changeset 2129:32f1bbf5917e

Slightly rework room_topic -u implementation
author Mikael Berthe <mikael@lilotux.net>
date Tue, 24 Jun 2014 19:42:41 +0200
parents adcff2d51ecb
children da426904eeda
files mcabber/mcabber/commands.c
diffstat 1 files changed, 11 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/mcabber/commands.c	Tue Jun 24 19:10:57 2014 +0200
+++ b/mcabber/mcabber/commands.c	Tue Jun 24 19:42:41 2014 +0200
@@ -2942,20 +2942,18 @@
     char *unescaped_topic = NULL;
 
     if (!strncmp(arg, "-u ", 3)) {
-      char *tmp;
-      tmp = g_strdup(arg + 3);
-      g_free(arg);
-      arg = tmp;
+      char *tmp = arg;
+      arg = g_strdup(arg + 3);
+      g_free(tmp);
       unescaped_topic = ut_unescape_tabs_cr(arg);
-    }
-
-    // We must not free() if the original string was returned
-    if (unescaped_topic == arg)
-      unescaped_topic = NULL;
-
-    if (unescaped_topic != NULL) {
-      g_free(arg);
-      arg = unescaped_topic;
+
+      // We must not free() if the original string was returned
+      if (unescaped_topic == arg) {
+        unescaped_topic = NULL;
+      } else if (unescaped_topic != NULL) {
+        g_free(arg);
+        arg = unescaped_topic;
+      }
     }
   }