cake
/
libp7
Archived
1
0
Fork 1

segfault caused by a log_info... no more segfault.

This commit is contained in:
Thomas Touhey 2017-01-19 15:24:56 +01:00
parent 63ac24c050
commit af3e1122b5
3 changed files with 9 additions and 5 deletions

View File

@ -121,7 +121,7 @@ int p7_fdinit(p7_handle_t **handle, int active, int check,
const char *name, int readfd, int writefd);
/* De-initialization */
void p7_exit(p7_handle_t *handle, int term, int free);
void p7_exit(p7_handle_t *handle, int term);
/* ************************************************************************** */
/* Protocol */
/* ************************************************************************** */

View File

@ -108,6 +108,9 @@ int p7_command_is_supported(unsigned int code, const p7_env_t *env);
/* ************************************************************************** */
/* main structure */
struct p7_handle_s {
/* was allocated */
int _wasalloc;
/* stream */
p7_stream_t *_stream;
p7_stream_t _stream_data;

View File

@ -143,6 +143,7 @@ int p7_sinit(p7_handle_t **h, int active, int check,
/* initialize handle */
p7_handle_t *handle = *h;
bzero(handle, sizeof(p7_handle_t));
handle->_wasalloc = alloc;
handle->_stream_data = dstream;
handle->_stream = &handle->_stream_data;
handle->_response = &handle->_response_data;
@ -183,7 +184,7 @@ int p7_sinit(p7_handle_t **h, int active, int check,
/* initialization went alright */
return (0);
fail:
p7_exit(*h, 0, alloc);
p7_exit(*h, 0);
*h = NULL;
return (err);
}
@ -200,7 +201,7 @@ fail:
* @arg wasalloc should we free the handle?
*/
void p7_exit(p7_handle_t *handle, int term, int wasalloc)
void p7_exit(p7_handle_t *handle, int term)
{
log_info("exit is called.");
/* check if handle is already freed */
@ -220,6 +221,6 @@ void p7_exit(p7_handle_t *handle, int term, int wasalloc)
(*handle->_stream->close)(handle->_stream->cookie);
/* free handle */
if (wasalloc) free(handle);
log_info("handle is freeeeeeeeed :D");
log_info("freeing the handle!");
if (handle->_wasalloc) free(handle);
}