mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-25 15:37:32 +00:00
netutils/ftpc: Fix some memory leaks
This commit is contained in:
parent
19acc8ad4e
commit
158cbeb151
3 changed files with 15 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* apps/netutils/ftpc/ftpc_chdir.c
|
||||
*
|
||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2011, 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
|
@ -86,6 +86,13 @@ int ftpc_chdir(SESSION handle, FAR const char *path)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* Free any previous setting and set the new working directory */
|
||||
|
||||
if (session->currdir != NULL)
|
||||
{
|
||||
free(session->currdir);
|
||||
}
|
||||
|
||||
session->currdir = ftpc_rpwd(handle);
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ SESSION ftpc_connect(FAR struct ftpc_connect_s *server)
|
|||
*/
|
||||
|
||||
session->homeldir = strdup(ftpc_lpwd());
|
||||
/* session->curldir = strdup(sssion->homeldir); */
|
||||
/* session->curldir = strdup(session->homeldir); */
|
||||
|
||||
/* Create up a timer to prevent hangs */
|
||||
|
||||
|
|
@ -123,6 +123,11 @@ SESSION ftpc_connect(FAR struct ftpc_connect_s *server)
|
|||
return (SESSION)session;
|
||||
|
||||
errout_with_alloc:
|
||||
if (session->homeldir != NULL)
|
||||
{
|
||||
free(session->homeldir);
|
||||
}
|
||||
|
||||
free(session);
|
||||
errout:
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ void ftpc_disconnect(SESSION handle)
|
|||
free(session->pwd);
|
||||
free(session->initrdir);
|
||||
free(session->homerdir);
|
||||
free(session->homeldir);
|
||||
free(session->currdir);
|
||||
|
||||
/* Then destroy the session */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue