summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBernd Edlinger <bernd.edlinger@hotmail.de>2017-02-14 16:38:02 +0100
committerRich Salz <rsalz@openssl.org>2017-02-15 08:44:05 -0500
commitb75dbf3c118aeee4b1a71f882eb30ba7cefba486 (patch)
tree9609595bc4d9cc11f33b159e29ee76596bb12da0 /apps
parent9b9f8315dc3b205e19f04565efe54fbac62f9a30 (diff)
Fix some realloc error handling issues.
Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2625)
Diffstat (limited to 'apps')
-rw-r--r--apps/engine.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/apps/engine.c b/apps/engine.c
index f54631b50d..a8eed9af5c 100644
--- a/apps/engine.c
+++ b/apps/engine.c
@@ -108,13 +108,16 @@ static int append_buf(char **buf, const char *s, int *size, int step)
}
if (strlen(*buf) + strlen(s) >= (unsigned int)*size) {
+ char *p = *buf;
+
*size += step;
*buf = OPENSSL_realloc(*buf, *size);
+ if (*buf == NULL) {
+ OPENSSL_free(p);
+ return 0;
+ }
}
- if (*buf == NULL)
- return 0;
-
if (**buf != '\0')
BUF_strlcat(*buf, ", ", *size);
BUF_strlcat(*buf, s, *size);