Fix resource leak issues, file not close case

Partial-Bug: 1794903

Change-Id: Id6de282c27374d578a0a41869ec6a934e6675db4
Signed-off-by: Martin Chen <haochuan.z.chen@intel.com>
This commit is contained in:
Martin Chen 2018-10-19 04:37:28 +08:00
parent 0362090b73
commit c89f0ffa20
2 changed files with 3 additions and 2 deletions

View File

@ -784,6 +784,7 @@ string get_shadow_signature ( char * shadowfile , const char * username,
int ret = snprintf(shadowinfo, infolen, "%s", shadowEntry);
if (ret >= (int)infolen)
{
fclose(file_ptr);
elog("insufficient space in shadow buffer(%d) for %d bytes\n",
(int)infolen, ret);
return ( "" );

View File

@ -328,8 +328,8 @@ int add_rmon_client ( const char * process_name_ptr, int port , const char * reg
fprintf(pFile, "%s\n", rmon.rmon_rx_buf);
// release write lock
flock(fileno(pFile), LOCK_UN);
fclose(pFile);
}
fclose(pFile);
}
else
{
@ -442,8 +442,8 @@ int remove_rmon_client( const char * process_name_ptr, int socket )
fprintf(pFile, "%s\n", rmon.rmon_rx_buf);
// release the lock
flock(fileno(pFile), LOCK_UN);
fclose(pFile);
}
fclose(pFile);
} else {
syslog (LOG_ERR, "Failed to open '%s'\n",
RMON_API_DEREG_DIR );