diff options
author | FreeArtMan <dos21h@gmail.com> | 2020-04-15 19:51:13 +0100 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2020-04-15 19:51:13 +0100 |
commit | 6c44c2e89000444b1bdf790452fd1b92d121ed06 (patch) | |
tree | 8ac22698c6884cccb4c2a658f57755c40ad0740f /core.c | |
parent | 786bd1e76c6806a4c9272814f9ffe7d901998e4e (diff) | |
download | ihe-6c44c2e89000444b1bdf790452fd1b92d121ed06.tar.gz ihe-6c44c2e89000444b1bdf790452fd1b92d121ed06.zip |
Cleared one memleak on open/close workflow
Diffstat (limited to 'core.c')
-rw-r--r-- | core.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -112,6 +112,19 @@ int file_open_fn( file_t *ft, const char *filename, int flags ) int ret = 0; int fd; + //check if file is allready initialized or opened + if (ft->fd > 0) + { + printf("Trying to open file but file descriptor allready set\n"); + return -1; + } + + if (ft->filename != NULL) + { + printf("Trying open file, bus structure allready have filename\n"); + return -1; + } + fd = fd_open( filename, flags ); if ( fd < 1 ) { @@ -378,10 +391,14 @@ int file_close( file_t *ft ) { printf("File name is empty\n"); return -1; + } else { + free(ft->filename); + ft->filename = NULL; } fd_close( ft->fd ); memset( ft, 0, sizeof(file_t) ); + ft->fd = -1; return ret; } |