comparison mcabber/src/jabglue.c @ 1071:866be086cc9b

Fix a memory leak in JEP22 handling
author Mikael Berthe <mikael@lilotux.net>
date Sun, 03 Dec 2006 12:00:17 +0100
parents a5dc85fdebde
children 2a3cfb98bd5e
comparison
equal deleted inserted replaced
1070:9eaacc0ad3a2 1071:866be086cc9b
493 jb_setstatus(mywantedstatus, NULL, mystatusmsg, FALSE); 493 jb_setstatus(mywantedstatus, NULL, mystatusmsg, FALSE);
494 } 494 }
495 495
496 // new_msgid() 496 // new_msgid()
497 // Generate a new id string. The caller should free it. 497 // Generate a new id string. The caller should free it.
498 // The caller must free the string when no longer needed.
498 static char *new_msgid(void) 499 static char *new_msgid(void)
499 { 500 {
500 static guint msg_idn; 501 static guint msg_idn;
501 time_t now; 502 time_t now;
502 time(&now); 503 time(&now);
520 #endif 521 #endif
521 #if defined JEP0022 || defined JEP0085 522 #if defined JEP0022 || defined JEP0085
522 xmlnode event; 523 xmlnode event;
523 guint use_jep85 = 0; 524 guint use_jep85 = 0;
524 struct jep0085 *jep85 = NULL; 525 struct jep0085 *jep85 = NULL;
526 #endif
527 #if defined JEP0022
528 gchar *nmsgid = NULL;
525 #endif 529 #endif
526 gchar *enc = NULL; 530 gchar *enc = NULL;
527 531
528 if (encrypted) 532 if (encrypted)
529 *encrypted = FALSE; 533 *encrypted = FALSE;
629 if (jep22) 633 if (jep22)
630 jep22->last_state_sent = ROSTER_EVENT_ACTIVE; 634 jep22->last_state_sent = ROSTER_EVENT_ACTIVE;
631 635
632 // An id is mandatory when using JEP-0022. 636 // An id is mandatory when using JEP-0022.
633 if (!msgid && (text || subject)) { 637 if (!msgid && (text || subject)) {
634 msgid = new_msgid(); 638 msgid = nmsgid = new_msgid();
635 // Let's update last_msgid_sent 639 // Let's update last_msgid_sent
636 // (We do not update it when the msgid is provided by the caller, 640 // (We do not update it when the msgid is provided by the caller,
637 // because this is probably a special message...) 641 // because this is probably a special message...)
638 if (jep22) { 642 if (jep22) {
639 g_free(jep22->last_msgid_sent); 643 g_free(jep22->last_msgid_sent);
646 jb_send_msg_no_chatstates: 650 jb_send_msg_no_chatstates:
647 xmlnode_put_attrib(x, "id", msgid); 651 xmlnode_put_attrib(x, "id", msgid);
648 652
649 jab_send(jc, x); 653 jab_send(jc, x);
650 xmlnode_free(x); 654 xmlnode_free(x);
655 #if defined JEP0022
656 g_free(nmsgid);
657 #endif
651 658
652 jb_reset_keepalive(); 659 jb_reset_keepalive();
653 } 660 }
654 661
655 662