summaryrefslogtreecommitdiffstats
path: root/src/tools.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-11 17:06:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-11 17:06:50 +0000
commit889a8235a21475be105941679b10f92532d26ac1 (patch)
tree19c3c098346c0d07f306e64960bb66ff452a650d /src/tools.c
parentAdding upstream version 3.0.0. (diff)
downloadhaproxy-889a8235a21475be105941679b10f92532d26ac1.tar.xz
haproxy-889a8235a21475be105941679b10f92532d26ac1.zip
Adding upstream version 3.0.1.upstream/3.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools.c')
-rw-r--r--src/tools.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/tools.c b/src/tools.c
index 7608e7e..b297d04 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -4627,8 +4627,9 @@ int my_unsetenv(const char *name)
* corresponding value. A variable is identified as a series of alphanumeric
* characters or underscores following a '$' sign. The <in> string must be
* free()able. NULL returns NULL. The resulting string might be reallocated if
- * some expansion is made. Variable names may also be enclosed into braces if
- * needed (eg: to concatenate alphanum characters).
+ * some expansion is made (an NULL will be returned on failure). Variable names
+ * may also be enclosed into braces if needed (eg: to concatenate alphanum
+ * characters).
*/
char *env_expand(char *in)
{
@@ -4683,6 +4684,9 @@ char *env_expand(char *in)
}
out = my_realloc2(out, out_len + (txt_end - txt_beg) + val_len + 1);
+ if (!out)
+ goto leave;
+
if (txt_end > txt_beg) {
memcpy(out + out_len, txt_beg, txt_end - txt_beg);
out_len += txt_end - txt_beg;
@@ -4697,6 +4701,7 @@ char *env_expand(char *in)
/* here we know that <out> was allocated and that we don't need <in> anymore */
free(in);
+leave:
return out;
}