Skip to content

Commit 22e6624

Browse files
committed
event_routing: avoid shm leak on error
1 parent 37dca65 commit 22e6624

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

modules/event_routing/event_routing.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -457,18 +457,18 @@ static int wait_for_event_sync(struct sip_msg* msg,
457457
/* do the init of the event*/
458458
if (init_ebr_event(event) < 0) {
459459
LM_ERR("failed to init event\n");
460-
goto done;
460+
goto done1;
461461
}
462462
}
463463

464464
swait_data = (struct swait_pack*)shm_malloc( sizeof(struct swait_pack) );
465465
if (swait_data==NULL) {
466466
LM_ERR("failed to allocated SWAIT data\n");
467-
goto done;
467+
goto done1;
468468
}
469469
if (cond_init(&swait_data->cond) != 0) {
470470
LM_ERR("could not initialize subscription cond\n");
471-
goto done;
471+
goto done2;
472472
}
473473
swait_data->ret_avps = NULL; /*to be populated on resume*/
474474

@@ -477,7 +477,7 @@ static int wait_for_event_sync(struct sip_msg* msg,
477477
*timeout, NULL, (void*)swait_data, EBR_SUBS_TYPE_SWAIT) < 0) {
478478
LM_ERR("failed to add ebr subscription for event %d\n",
479479
event->event_id);
480-
goto done1;
480+
goto done3;
481481
}
482482

483483
/* now just wait on the codition */
@@ -499,10 +499,13 @@ static int wait_for_event_sync(struct sip_msg* msg,
499499
}
500500

501501
return rc == 0 ? 1 : rc;
502-
done1:
502+
done3:
503503
cond_destroy(&swait_data->cond);
504-
done:
504+
done2:
505505
shm_free(swait_data);
506+
done1:
507+
shm_free_all(filters);
508+
done:
506509
return rc;
507510
}
508511

0 commit comments

Comments
 (0)