From: Russell Bryant Date: Thu, 1 Jul 2010 22:09:19 +0000 (+0000) Subject: Don't return a partially initialized datastore. X-Git-Tag: 1.4.35-rc1~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2a18c6627d4e3ee410ab56d86ae1e4070a92e6ab;p=thirdparty%2Fasterisk.git 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 --- 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; }