summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/haserl.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/haserl.c b/src/haserl.c
index 641e820..fbfca7e 100644
--- a/src/haserl.c
+++ b/src/haserl.c
@@ -204,6 +204,7 @@ myputenv (list_t * cur, char *str, char *prefix)
char *entry = NULL;
char *temp = NULL;
int array = 0;
+ int len;
keylen = (size_t) ((char *) memchr (str, '=', strlen (str)) - (char *) str);
if (keylen <= 0)
@@ -223,7 +224,6 @@ myputenv (list_t * cur, char *str, char *prefix)
if (strlen (prefix))
{
strncat (entry, prefix, strlen (prefix));
- keylen+= strlen(prefix);
}
if (array == 1)
@@ -237,14 +237,15 @@ myputenv (list_t * cur, char *str, char *prefix)
}
/* does the value already exist? */
+ len = keylen + strlen(prefix) + 1;
while (cur != NULL)
{
- if (memcmp (cur->buf, entry, keylen + 1) == 0)
+ if (memcmp (cur->buf, entry, len) == 0)
{
if (array == 1)
{
/* if an array, add this value to the old array */
- temp = xmalloc (strlen (cur->buf) + strlen (entry + keylen));
+ temp = xmalloc (strlen (cur->buf) + len );
memmove (temp, cur->buf, strlen (cur->buf));
strcat (temp, "\n");
strcat (temp, str + keylen + 3);