diff options
author | Jenkins2 <jenkins2@gerrit.asterisk.org> | 2017-11-07 06:41:50 -0600 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2017-11-07 06:41:50 -0600 |
commit | 37863c163c51a29b21871e0d05c62b268c1aaeb5 (patch) | |
tree | 4e1515eeadefa786a20afa18795b889020198782 /include | |
parent | 36b5a66c27582e0b54d5dababec93f78fc272f73 (diff) | |
parent | 9013415593868b2d31a895e3f1f209fc21b58384 (diff) |
Merge "Fix ast_(v)asprintf() malloc failure usage conditions." into 13
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/utils.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index 4a5dbf282..03705b321 100644 --- a/include/asterisk/utils.h +++ b/include/asterisk/utils.h @@ -721,7 +721,13 @@ int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, c DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, -1); - if ((res = vasprintf(ret, fmt, ap)) == -1) { + res = vasprintf(ret, fmt, ap); + if (res < 0) { + /* + * *ret is undefined so set to NULL to ensure it is + * initialized to something useful. + */ + *ret = NULL; MALLOC_FAILURE_MSG; } |