]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 26 Apr 2007 14:38:40 +0000 (14:38 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 26 Apr 2007 14:38:40 +0000 (14:38 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5019 d0543943-73ff-0310-b7d9-9358b9ac24b2

libs/libdingaling/src/libdingaling.c

index 8ac480f61ecd4f7675d48af2435603445fcf6b13..7b766d776dd57dd81f9126c7ae84ba6c49eda88e 100644 (file)
@@ -1716,18 +1716,19 @@ static void ldl_random_string(char *buf, uint16_t len, char *set)
     }
 }
 
-
+#define TLEN 8192
 void ldl_handle_send_vcard(ldl_handle_t *handle, char *from, char *to, char *id, char *vcard)
 {
-       iks *vxml, *iq;
+       iks *vxml = NULL, *iq = NULL;
        int e = 0;
-       ldl_avatar_t *ap;
+       ldl_avatar_t *ap = NULL;
+       char *text = NULL;
 
        ap = ldl_get_avatar(handle, NULL, from);
 
        if (!vcard) {
-               char text[8192];
                char *ext;
+
                if (!ap) {
                        return;
                }
@@ -1737,8 +1738,8 @@ void ldl_handle_send_vcard(ldl_handle_t *handle, char *from, char *to, char *id,
                } else {
                        ext = "png";
                }
-
-               snprintf(text, sizeof(text),
+               text = malloc(TLEN);
+               snprintf(text, TLEN,
                                 "<vCard xmlns='vcard-temp'><PHOTO><TYPE>image/%s</TYPE><BINVAL>%s</BINVAL></PHOTO></vCard>",
                                 ext,
                                 ap->base64
@@ -1753,12 +1754,12 @@ void ldl_handle_send_vcard(ldl_handle_t *handle, char *from, char *to, char *id,
 
        if (!(vxml = iks_tree(vcard, 0, &e))) {
                globals.logger(DL_LOG_ERR, "Parse returned error [%d]\n", e);
-               return;
+               goto fail;
        }
        
        if (!(iq = iks_new("iq"))) {
                globals.logger(DL_LOG_ERR, "Memory Error\n");
-               return;
+               goto fail;
        }
 
        if (!iks_insert_attrib(iq, "to", to)) goto fail;
@@ -1769,17 +1770,24 @@ void ldl_handle_send_vcard(ldl_handle_t *handle, char *from, char *to, char *id,
        if (!iks_insert_node(iq, vxml)) goto fail;
 
        apr_queue_push(handle->queue, iq);
+
        iq = NULL;
        vxml = NULL;
 
  fail:
+
        if (iq) {
                iks_delete(iq);
        }
+
        if (vxml) {
                iks_delete(vxml);
        }
 
+       if (text) {
+               free(text);
+       }
+
 }
 
 void ldl_handle_send_msg(ldl_handle_t *handle, char *from, char *to, char *subject, char *body)