summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nuttx/ChangeLog4
-rw-r--r--nuttx/Documentation/NuttX.html4
-rw-r--r--nuttx/sched/env_dup.c4
-rw-r--r--nuttx/sched/env_getenv.c2
4 files changed, 9 insertions, 5 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index adf20a906..81188709c 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -191,6 +191,8 @@
* Add environment variables APIs: environ, getenv, putenv, clearenv, setenv,
unsetenv
* Correct an error in realloc() when the block is extended "down" in memory.
- In this case, the old memory contents need to be copied to the new location.
+ In this case, the old memory contents need to be copied to the new location
+ and an allocated bit was not being set.
+ * examples/ostest: Added an environment variable test.
* Started m68322
diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
index e19cf3d0d..fad801a84 100644
--- a/nuttx/Documentation/NuttX.html
+++ b/nuttx/Documentation/NuttX.html
@@ -628,7 +628,9 @@ Other memory:
* Add environment variables APIs: environ, getenv, putenv, clearenv, setenv,
unsetenv
* Correct an error in realloc() when the block is extended "down" in memory.
- In this case, the old memory contents need to be copied to the new location.
+ In this case, the old memory contents need to be copied to the new location
+ and an allocated bit was not being set.
+ * examples/ostest: Added an environment variable test.
* Started m68322
</pre></ul>
diff --git a/nuttx/sched/env_dup.c b/nuttx/sched/env_dup.c
index 0ee1cbc81..671b8ea7b 100644
--- a/nuttx/sched/env_dup.c
+++ b/nuttx/sched/env_dup.c
@@ -99,7 +99,7 @@ int env_dup(FAR _TCB *ptcb)
{
/* Yes..The parent task has an environment, duplicate it */
- size_t envlen = ptcb->envp->ev_alloc;
+ size_t envlen = parent->envp->ev_alloc;
envp = (environ_t*)malloc(SIZEOF_ENVIRON_T( envlen ));
if (!envp)
{
@@ -109,7 +109,7 @@ int env_dup(FAR _TCB *ptcb)
{
envp->ev_crefs = 1;
envp->ev_alloc = envlen;
- memcmp( envp->ev_env, ptcb->envp->ev_env, envlen );
+ memcpy( envp->ev_env, parent->envp->ev_env, envlen );
}
}
diff --git a/nuttx/sched/env_getenv.c b/nuttx/sched/env_getenv.c
index a1de739a9..91e974845 100644
--- a/nuttx/sched/env_getenv.c
+++ b/nuttx/sched/env_getenv.c
@@ -100,7 +100,7 @@ FAR char *getenv(const char *name)
/* Check if the variable exists */
- if ( envp && (pvar = env_findvar(envp, name)) != NULL)
+ if ( !envp || (pvar = env_findvar(envp, name)) == NULL)
{
ret = ENOENT;
goto errout_with_lock;