]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 273566 via svnmerge from
authorRussell Bryant <russell@russellbryant.com>
Thu, 1 Jul 2010 22:17:57 +0000 (22:17 +0000)
committerRussell Bryant <russell@russellbryant.com>
Thu, 1 Jul 2010 22:17:57 +0000 (22:17 +0000)
https://origsvn.digium.com/svn/asterisk/trunk

................
  r273566 | russell | 2010-07-01 17:16:23 -0500 (Thu, 01 Jul 2010) | 14 lines

  Merged revisions 273565 via svnmerge from
  https://origsvn.digium.com/svn/asterisk/branches/1.4

  ........
    r273565 | russell | 2010-07-01 17:09:19 -0500 (Thu, 01 Jul 2010) | 7 lines

    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.6.2@273571 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/datastore.c

index 3d097860fce8d50fd803a0fe37cc6991acdaf736..ee471551d184a03ddd91e056362aeda762e115f9 100644 (file)
@@ -50,7 +50,10 @@ struct ast_datastore *__ast_datastore_alloc(const struct ast_datastore_info *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;
 }