aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2010-07-01 22:09:19 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2010-07-01 22:09:19 +0000
commit9a7a303614a64cc79a14476b5126115a5c600e67 (patch)
treef63de9f0ea3b7897f83bf183cd58ef0aff250bc2
parentdf3e95c62ff9cd3d57879bc213260d0bf08df5b3 (diff)
Don't return a partially initialized datastore.
If memory allocation fails in ast_strdup(), don't return a partially initialized datastore. Bad things may happen. (related to ABE-2415) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@273565 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--main/channel.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/main/channel.c b/main/channel.c
index 70324d9e5..b10c07cfe 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -1439,7 +1439,10 @@ struct ast_datastore *ast_channel_datastore_alloc(const struct ast_datastore_inf
datastore->info = info;
- datastore->uid = ast_strdup(uid);
+ if (!ast_strlen_zero(uid) && !(datastore->uid = ast_strdup(uid))) {
+ ast_free(datastore);
+ datastore = NULL;
+ }
return datastore;
}