aboutsummaryrefslogtreecommitdiffhomepage
path: root/env.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-02-17 11:42:53 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-02-17 11:42:53 -0800
commit4fd2531302717e8947e549c1fa55d7f73fb31901 (patch)
treedaa3442081b112b707e2610417046d29a6542d5d /env.cpp
parentfdef238a83d34406144efd0be979b18d6b4d8b52 (diff)
Fix to properly null-terminate export list
Diffstat (limited to 'env.cpp')
-rw-r--r--env.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/env.cpp b/env.cpp
index 8146cf33..75445475 100644
--- a/env.cpp
+++ b/env.cpp
@@ -1667,7 +1667,7 @@ char **env_export_arr( int recalc )
export_func2(vals, &export_buffer );
export_arr = (char **)realloc( export_arr,
- sizeof(char *)*(vals.size()) + 4) ; //REVIEW I replaced 1 with 4 because I was getting an invalid write of 4 bytes for export[arr] = 0 below
+ sizeof(char *)*(1 + vals.size())); //add 1 for null termination
for( i=0; i<export_buffer.used; i++ )
{
@@ -1678,7 +1678,7 @@ char **env_export_arr( int recalc )
}
prev_was_null = (export_buffer.buff[i]==0);
}
- export_arr[pos]=0; // REVIEW <- This is why I have changed 1 with 4
+ export_arr[pos]=NULL;
has_changed=0;
}