summaryrefslogtreecommitdiffstats
path: root/src/stk.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-06-16 15:55:53 +0200
committerMarcel Holtmann <marcel@holtmann.org>2010-06-16 15:55:53 +0200
commite2790ba6465e956a167b1e2622641d941c721a51 (patch)
tree076993ef4d3639fbe444f35755656dd21b9ce330 /src/stk.c
parent6719c0b93ff9c28d945152fa63186a819ba9f141 (diff)
downloadofono-e2790ba6465e956a167b1e2622641d941c721a51.tar.bz2
Fix memory allocation handling for STK Proactive command debug
Diffstat (limited to 'src/stk.c')
-rw-r--r--src/stk.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/stk.c b/src/stk.c
index e307a4e5..b95708e4 100644
--- a/src/stk.c
+++ b/src/stk.c
@@ -84,17 +84,19 @@ void ofono_stk_proactive_command_notify(struct ofono_stk *stk,
{
struct stk_command *cmd;
char *buf;
- int i;
- buf = g_try_new(char, length * 2 + 1);
- for (i = 0; i < length; i ++)
- sprintf(buf + i * 2, "%02hhx", pdu[i]);
- DBG("Proactive command PDU: %s", buf);
+ buf = g_try_malloc(length * 2 + 1);
+ if (buf) {
+ int i;
+ for (i = 0; i < length; i ++)
+ sprintf(buf + i * 2, "%02hhx", pdu[i]);
+ ofono_info("Proactive command PDU: %s", buf);
+ g_free(buf);
+ }
cmd = stk_command_new_from_pdu(pdu, length);
if (!cmd) {
ofono_error("Can't parse proactive command: %s", buf);
- g_free(buf);
/* TODO: return TERMINAL RESPONSE with permanent error */
return;
@@ -102,7 +104,6 @@ void ofono_stk_proactive_command_notify(struct ofono_stk *stk,
/* TODO: execute */
- g_free(buf);
stk_command_free(cmd);
}