comparison mcabber/src/jabglue.c @ 473:c024d1d5d350

Fix segfault when receiving a message stanza with no body tag
author Mikael Berthe <mikael@lilotux.net>
date Sun, 02 Oct 2005 22:31:36 +0200
parents 75442262c082
children 27efa1e2671a
comparison
equal deleted inserted replaced
472:75442262c082 473:c024d1d5d350
832 case JPACKET_MESSAGE: 832 case JPACKET_MESSAGE:
833 { 833 {
834 char *tmp = NULL; 834 char *tmp = NULL;
835 time_t timestamp = 0; 835 time_t timestamp = 0;
836 836
837 x = xmlnode_get_tag(packet->x, "body"); 837 body = xmlnode_get_tag_data(packet->x, "body");
838 p = xmlnode_get_data(x); if (p) body = p; 838
839 839 p = xmlnode_get_tag_data(packet->x, "subject");
840 if ((x = xmlnode_get_tag(packet->x, "subject")) != NULL) 840 if (p != NULL) {
841 if ((p = xmlnode_get_data(x)) != NULL) { 841 if (type && !strcmp(type, "groupchat")) {
842 tmp = g_new(char, strlen(body)+strlen(p)+4); 842 // That's a room topic
843 } else {
844 tmp = g_new(char, (body ? strlen(body) : 0) + strlen(p) + 4);
843 *tmp = '['; 845 *tmp = '[';
844 strcpy(tmp+1, p); 846 strcpy(tmp+1, p);
845 strcat(tmp, "]\n"); 847 strcat(tmp, "]\n");
846 strcat(tmp, body); 848 if (body) strcat(tmp, body);
847 body = tmp; 849 body = tmp;
848 } 850 }
851 }
849 852
850 /* there can be multiple <x> tags. we're looking for one with 853 /* there can be multiple <x> tags. we're looking for one with
851 xmlns = jabber:x:encrypted */ 854 xmlns = jabber:x:encrypted */
852 855
853 x = xmlnode_get_firstchild(packet->x); 856 x = xmlnode_get_firstchild(packet->x);