Skip to content
Snippets Groups Projects
Commit cdd8fe23 authored by patacongo's avatar patacongo
Browse files

Add environment variable test; fix several detected bugs

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@298 42af7a65-404d-4744-a932-0658087f49c3
parent c418e219
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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>
......
......@@ -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 );
}
}
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment