Correct a memory leak in NSH
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5600 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
cca7618daa
commit
7f474703fa
@ -140,16 +140,16 @@ int exec_builtin(FAR const char *appname, FAR char * const *argv,
|
||||
|
||||
/* Initialize attributes for task_spawn(). */
|
||||
|
||||
ret = posix_spawn_file_actions_init(&file_actions);
|
||||
ret = posix_spawnattr_init(&attr);
|
||||
if (ret != 0)
|
||||
{
|
||||
goto errout_with_errno;
|
||||
}
|
||||
|
||||
ret = posix_spawnattr_init(&attr);
|
||||
ret = posix_spawn_file_actions_init(&file_actions);
|
||||
if (ret != 0)
|
||||
{
|
||||
goto errout_with_errno;
|
||||
goto errout_with_attrs;
|
||||
}
|
||||
|
||||
/* Set the correct task size and priority */
|
||||
@ -158,13 +158,13 @@ int exec_builtin(FAR const char *appname, FAR char * const *argv,
|
||||
ret = posix_spawnattr_setschedparam(&attr, ¶m);
|
||||
if (ret != 0)
|
||||
{
|
||||
goto errout_with_errno;
|
||||
goto errout_with_actions;
|
||||
}
|
||||
|
||||
ret = task_spawnattr_setstacksize(&attr, builtin->stacksize);
|
||||
if (ret != 0)
|
||||
{
|
||||
goto errout_with_errno;
|
||||
goto errout_with_actions;
|
||||
}
|
||||
|
||||
/* If robin robin scheduling is enabled, then set the scheduling policy
|
||||
@ -175,7 +175,7 @@ int exec_builtin(FAR const char *appname, FAR char * const *argv,
|
||||
ret = posix_spawnattr_setschedpolicy(&attr, SCHED_RR);
|
||||
if (ret != 0)
|
||||
{
|
||||
goto errout_with_errno;
|
||||
goto errout_with_actions;
|
||||
}
|
||||
|
||||
ret = posix_spawnattr_setflags(&attr,
|
||||
@ -183,13 +183,13 @@ int exec_builtin(FAR const char *appname, FAR char * const *argv,
|
||||
POSIX_SPAWN_SETSCHEDULER);
|
||||
if (ret != 0)
|
||||
{
|
||||
goto errout_with_errno;
|
||||
goto errout_with_actions;
|
||||
}
|
||||
#else
|
||||
ret = posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSCHEDPARAM);
|
||||
if (ret != 0)
|
||||
{
|
||||
goto errout_with_errno;
|
||||
goto errout_with_actions;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -204,7 +204,7 @@ int exec_builtin(FAR const char *appname, FAR char * const *argv,
|
||||
if (ret != 0)
|
||||
{
|
||||
sdbg("ERROR: posix_spawn_file_actions_addopen failed: %d\n", ret);
|
||||
goto errout_with_errno;
|
||||
goto errout_with_actions;
|
||||
}
|
||||
}
|
||||
|
||||
@ -216,16 +216,28 @@ int exec_builtin(FAR const char *appname, FAR char * const *argv,
|
||||
if (ret != 0)
|
||||
{
|
||||
sdbg("ERROR: task_spawn failed: %d\n", ret);
|
||||
goto errout_with_errno;
|
||||
goto errout_with_actions;
|
||||
}
|
||||
|
||||
/* Free attibutes and file actions. Ignoring return values in the case
|
||||
* of an error.
|
||||
*/
|
||||
|
||||
/* Return the task ID of the new task if the task was sucessfully
|
||||
* started. Otherwise, ret will be ERROR (and the errno value will
|
||||
* be set appropriately).
|
||||
*/
|
||||
|
||||
(void)posix_spawn_file_actions_destroy(&file_actions);
|
||||
(void)posix_spawnattr_destroy(&attr);
|
||||
return pid;
|
||||
|
||||
errout_with_actions:
|
||||
(void)posix_spawn_file_actions_destroy(&file_actions);
|
||||
|
||||
errout_with_attrs:
|
||||
(void)posix_spawnattr_destroy(&attr);
|
||||
|
||||
errout_with_errno:
|
||||
set_errno(ret);
|
||||
return ERROR;
|
||||
|
@ -1424,6 +1424,13 @@ int nsh_parse(FAR struct nsh_vtbl_s *vtbl, char *cmdline)
|
||||
* successfully). So certainly it is not an NSH command.
|
||||
*/
|
||||
|
||||
/* Free the redirected output file path */
|
||||
|
||||
nsh_freefullpath(redirfile);
|
||||
redirfile = NULL;
|
||||
|
||||
/* Save the result: success if 0; failure if 1 */
|
||||
|
||||
return nsh_saveresult(vtbl, ret != OK);
|
||||
}
|
||||
|
||||
@ -1458,6 +1465,13 @@ int nsh_parse(FAR struct nsh_vtbl_s *vtbl, char *cmdline)
|
||||
* successfully). So certainly it is not an NSH command.
|
||||
*/
|
||||
|
||||
/* Free the redirected output file path */
|
||||
|
||||
nsh_freefullpath(redirfile);
|
||||
redirfile = NULL;
|
||||
|
||||
/* Save the result: success if 0; failure if 1 */
|
||||
|
||||
return nsh_saveresult(vtbl, ret != OK);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user