about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-10-02 01:35:41 +0100
committerJames Booth <boothj5@gmail.com>2014-10-02 01:35:41 +0100
commitbdad22e548cee6be0ad59e8e73295fdee754be31 (patch)
treef9cbdd0e9cd24d74cdbc29e66b5e88210506b137 /src
parentae4d83fb47f3e961e7f3d3655175a8240427c621 (diff)
parent92a0aba93fee94f6bacd995ff9345bbaeb901484 (diff)
downloadprofani-tty-bdad22e548cee6be0ad59e8e73295fdee754be31.tar.gz
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src')
-rw-r--r--src/command/commands.c14
-rw-r--r--src/ui/buffer.c12
2 files changed, 8 insertions, 18 deletions
diff --git a/src/command/commands.c b/src/command/commands.c
index 045ad00a..ed4afa80 100644
--- a/src/command/commands.c
+++ b/src/command/commands.c
@@ -1104,15 +1104,11 @@ cmd_msg(gchar **args, struct cmd_help_t help)
                     cons_show_error("Failed to send message. Please check OTR policy");
                     return TRUE;
                 } else if (policy == PROF_OTRPOLICY_OPPORTUNISTIC) {
-                    char *otr_base_tag = OTRL_MESSAGE_TAG_BASE;
-                    char *otr_v2_tag = OTRL_MESSAGE_TAG_V2;
-                    int N = strlen(otr_base_tag) + strlen(otr_v2_tag) + strlen(msg) + 1;
-                    char *temp = (char *) malloc( (unsigned) N*sizeof(char *) );
-                    strcpy( temp , msg );
-                    strcat( temp , otr_base_tag);
-                    strcat( temp, otr_v2_tag);
-                    message_send(temp, usr_jid);
-                    free(temp);
+                    GString *otr_message = g_string_new(msg);
+                    g_string_append(otr_message, OTRL_MESSAGE_TAG_BASE);
+                    g_string_append(otr_message, OTRL_MESSAGE_TAG_V2);
+                    message_send(otr_message->str, usr_jid);
+                    g_string_free(otr_message, TRUE);
                 } else {
                     message_send(msg, usr_jid);
                 }
diff --git a/src/ui/buffer.c b/src/ui/buffer.c
index ab5af17d..a1a992b1 100644
--- a/src/ui/buffer.c
+++ b/src/ui/buffer.c
@@ -87,15 +87,9 @@ buffer_push(ProfBuff buffer, const char show_char, const char * const date_fmt,
     e->show_char = show_char;
     e->flags = flags;
     e->attrs = attrs;
-
-    e->date_fmt = malloc(strlen(date_fmt)+1);
-    strcpy(e->date_fmt, date_fmt);
-
-    e->from = malloc(strlen(from)+1);
-    strcpy(e->from, from);
-
-    e->message = malloc(strlen(message)+1);
-    strcpy(e->message, message);
+    e->date_fmt = strdup(date_fmt);
+    e->from = strdup(from);
+    e->message = strdup(message);
 
     if (g_slist_length(buffer->entries) == BUFF_SIZE) {
         _free_entry(buffer->entries->data);