From e246b414c9c10e24c0b563e13ac230da2a3812cf Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Tue, 16 Mar 2010 17:40:44 -0500 Subject: [PATCH] Fix: Use g_try_malloc when parsing stk address --- src/stkutil.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/stkutil.c b/src/stkutil.c index a5c3ac0..afc92d6 100644 --- a/src/stkutil.c +++ b/src/stkutil.c @@ -57,6 +57,7 @@ static gboolean parse_dataobj_address(struct comprehension_tlv_iter *iter, struct stk_address *addr = user; const unsigned char *data; unsigned int len; + char *number; if (comprehension_tlv_iter_get_tag(iter) != STK_DATA_OBJECT_TYPE_ADDRESS) @@ -68,8 +69,12 @@ static gboolean parse_dataobj_address(struct comprehension_tlv_iter *iter, data = comprehension_tlv_iter_get_data(iter); + number = g_try_malloc(len * 2 - 1); + if (number == NULL) + return FALSE; + addr->ton_npi = data[0]; - addr->number = g_malloc(len * 2 - 1); + addr->number = number; extract_bcd_number(data + 1, len - 1, addr->number); return TRUE; -- 2.7.4