Skip to content

Commit 0f7be0e

Browse files
committed
Catching exception on failing to allocate memory
Signed-off-by: Rashmi <[email protected]>
1 parent a6d1fe3 commit 0f7be0e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lte/gateway/c/core/oai/tasks/s1ap/s1ap_state_manager.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ void S1apStateManager::init(uint32_t max_ues, uint32_t max_enbs,
6666
oai::S1apState* create_s1ap_state(void) {
6767
proto_map_uint32_enb_description_t enb_map;
6868

69-
oai::S1apState* state_cache_p = new oai::S1apState();
70-
if (!state_cache_p) {
69+
oai::S1apState* state_cache_p = nullptr;
70+
try {
71+
state_cache_p = new oai::S1apState();
72+
} catch (std::bad_alloc&) {
7173
OAILOG_CRITICAL(LOG_S1AP, "Failed allocate memory for S1apState");
7274
return state_cache_p;
7375
}

0 commit comments

Comments
 (0)