Slightly rework room_topic -u implementation
authorMikael Berthe <mikael@lilotux.net>
Tue, 24 Jun 2014 19:42:41 +0200
changeset 2129 32f1bbf5917e
parent 2128 adcff2d51ecb
child 2130 da426904eeda
Slightly rework room_topic -u implementation
mcabber/mcabber/commands.c
--- 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;
+      }
     }
   }