@@ -247,6 +247,19 @@ static inline int _set_msg_branch(struct msg_branch_wrap *br,
247247}
248248
249249
250+ static inline int _dst_malloc (struct dset_ctx * * dsct )
251+ {
252+ * dsct = pkg_malloc (sizeof * * dsct );
253+ if (* dsct == NULL ) {
254+ LM_ERR ("oom 1\n" );
255+ return E_OUT_OF_MEM ;
256+ }
257+ memset (* dsct , 0 , sizeof * * dsct );
258+ (* dsct )-> enabled = 1 ;
259+ store_dset_ctx (* dsct );
260+ return 0 ;
261+ }
262+
250263/* ! \brief
251264 * Add a new branch to current transaction
252265 */
@@ -259,16 +272,8 @@ int append_msg_branch(struct msg_branch *branch)
259272 if (dsct && !dsct -> enabled )
260273 return -1 ;
261274
262- if (!dsct ) {
263- dsct = pkg_malloc (sizeof * dsct );
264- if (!dsct ) {
265- LM_ERR ("oom 1\n" );
266- return E_OUT_OF_MEM ;
267- }
268- memset (dsct , 0 , sizeof * dsct );
269- dsct -> enabled = 1 ;
270- store_dset_ctx (dsct );
271- }
275+ if (dsct == NULL && _dst_malloc (& dsct )== 0 )
276+ return -1 ;
272277
273278 idx = dsct -> nr_branches ;
274279
@@ -905,7 +910,7 @@ int get_msg_branch_attr(unsigned int b_idx, int name_id,
905910 return -1 ;
906911 }
907912
908- // LM_DBG("getting attr [%d] on branch %d/ptr=%p\n",name_id, b_idx, attrs);
913+ LM_DBG ("getting attr [%d] on branch %d/ptr=%p\n" ,name_id , b_idx , attrs );
909914
910915 /* operate on the list of ATTRS/AVPS of the branch */
911916 old_list = set_avp_list ( attrs );
@@ -931,7 +936,9 @@ int set_msg_branch_attr(unsigned int b_idx, int name_id,
931936 struct usr_avp * avp ;
932937 struct usr_avp * * old_list ;
933938
934- if (!dsct )
939+ /* if we have to set an ATTR for RURI branch, we need to have the dset
940+ * allocated (as the attr holder is there) */
941+ if (dsct == NULL && (b_idx != 0 || (b_idx == 0 && _dst_malloc (& dsct )< 0 )) )
935942 return -1 ;
936943
937944 if (b_idx == 0 )
@@ -944,7 +951,7 @@ int set_msg_branch_attr(unsigned int b_idx, int name_id,
944951 return -1 ;
945952 }
946953
947- // LM_DBG("setting attr [%d] on branch %d/ptr=%p\n",name_id, b_idx, attrs);
954+ LM_DBG ("setting attr [%d] on branch %d/ptr=%p\n" ,name_id , b_idx , attrs );
948955
949956 /* operate on the list of ATTRS/AVPS of the branch */
950957 old_list = set_avp_list ( attrs );
0 commit comments