[Freeswitch-svn] [commit] r5019 - freeswitch/trunk/libs/libdingaling/src

Freeswitch SVN anthm at freeswitch.org
Thu Apr 26 10:38:40 EDT 2007


Author: anthm
Date: Thu Apr 26 10:38:40 2007
New Revision: 5019

Modified:
   freeswitch/trunk/libs/libdingaling/src/libdingaling.c

Log:
update

Modified: freeswitch/trunk/libs/libdingaling/src/libdingaling.c
==============================================================================
--- freeswitch/trunk/libs/libdingaling/src/libdingaling.c	(original)
+++ freeswitch/trunk/libs/libdingaling/src/libdingaling.c	Thu Apr 26 10:38:40 2007
@@ -1716,18 +1716,19 @@
     }
 }
 
-
+#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 @@
 		} 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 @@
 
 	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 @@
 	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)



More information about the Freeswitch-svn mailing list