From 55655a0480be1b68ac07f312b58901372739a0fc Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 26 Apr 2007 14:38:40 +0000 Subject: [PATCH] update git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5019 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/libdingaling/src/libdingaling.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/libs/libdingaling/src/libdingaling.c b/libs/libdingaling/src/libdingaling.c index 8ac480f61e..7b766d776d 100644 --- a/libs/libdingaling/src/libdingaling.c +++ b/libs/libdingaling/src/libdingaling.c @@ -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, "image/%s%s", 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)