comparison libfdproto/messages.c @ 1172:83d55d26ae80

Hand the case of invalid objects in the msg_dump functions
author Sebastien Decugis <sdecugis@freediameter.net>
date Mon, 03 Jun 2013 10:28:33 +0800
parents 98d1ad9bf85a
children d0a7b76a3c1c
comparison
equal deleted inserted replaced
1171:5dab72369dff 1172:83d55d26ae80
734 /* Core function to process the dumping */ 734 /* Core function to process the dumping */
735 static DECLARE_FD_DUMP_PROTOTYPE( msg_dump_process, msg_dump_formatter_msg msg_format, msg_dump_formatter_avp avp_format, msg_or_avp *obj, struct dictionary *dict, int force_parsing, int recurse ) 735 static DECLARE_FD_DUMP_PROTOTYPE( msg_dump_process, msg_dump_formatter_msg msg_format, msg_dump_formatter_avp avp_format, msg_or_avp *obj, struct dictionary *dict, int force_parsing, int recurse )
736 { 736 {
737 FD_DUMP_HANDLE_OFFSET(); 737 FD_DUMP_HANDLE_OFFSET();
738 738
739 if (!VALIDATE_OBJ(obj)) {
740 CHECK_MALLOC_DO( fd_dump_extend( FD_DUMP_STD_PARAMS, "INVALID MESSAGE OR AVP @%p"), return NULL);
741 return *buf;
742 }
743
739 if (force_parsing) { 744 if (force_parsing) {
740 (void) fd_msg_parse_dict(obj, dict, NULL); 745 (void) fd_msg_parse_dict(obj, dict, NULL);
741 } 746 }
742 747
743 switch (_C(obj)->type) { 748 switch (_C(obj)->type) {
749 CHECK_MALLOC_DO( (*msg_format)(FD_DUMP_STD_PARAMS, (struct msg *)obj), return NULL); 754 CHECK_MALLOC_DO( (*msg_format)(FD_DUMP_STD_PARAMS, (struct msg *)obj), return NULL);
750 break; 755 break;
751 756
752 default: 757 default:
753 ASSERT(0); 758 ASSERT(0);
759 free(*buf):
760 *buf = NULL;
761 return NULL;
754 } 762 }
755 763
756 if (recurse) { 764 if (recurse) {
757 struct avp * avp = NULL; 765 struct avp * avp = NULL;
758 int first = 1; 766 int first = 1;
"Welcome to our mercurial repository"