From 2a18c6627d4e3ee410ab56d86ae1e4070a92e6ab Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Thu, 1 Jul 2010 22:09:19 +0000 Subject: [PATCH] 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: https://origsvn.digium.com/svn/asterisk/branches/1.4@273565 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/channel.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/main/channel.c b/main/channel.c index 70324d9e50..b10c07cfe0 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; } -- 2.47.3