summaryrefslogtreecommitdiff
path: root/src/ivybind.c
diff options
context:
space:
mode:
authorfcolin2005-08-19 13:44:02 +0000
committerfcolin2005-08-19 13:44:02 +0000
commit0461197d573f0d38c3ce2c7e6ba55cb8c5727d42 (patch)
tree04d59a93302e2fce6c498adfa5f5415d4ba22b0e /src/ivybind.c
parent9921017a4b14b379d99305e17f8583ff90de0c1b (diff)
downloadivy-c-0461197d573f0d38c3ce2c7e6ba55cb8c5727d42.zip
ivy-c-0461197d573f0d38c3ce2c7e6ba55cb8c5727d42.tar.gz
ivy-c-0461197d573f0d38c3ce2c7e6ba55cb8c5727d42.tar.bz2
ivy-c-0461197d573f0d38c3ce2c7e6ba55cb8c5727d42.tar.xz
correction bug malloc free
Diffstat (limited to 'src/ivybind.c')
-rw-r--r--src/ivybind.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/ivybind.c b/src/ivybind.c
index 9d95e92..237ee78 100644
--- a/src/ivybind.c
+++ b/src/ivybind.c
@@ -49,7 +49,6 @@ static int err_offset;
#endif
struct _binding {
- struct _binding *next;
IvyBindingType type;
const char *msgname; /* msg tag name first word of message */
char **msgargs; /* list of msg argument name */
@@ -93,6 +92,8 @@ static IvyBinding IvyBindingCompileSimple( IvyBindingType typ, const char * expr
}
bind = (IvyBinding)malloc( sizeof( struct _binding ));
+ memset( bind, 0, sizeof(*bind ) );
+ bind->type = IvyBindSimple;
bind->msgname = strtok( expr, " ");
bind->msgargs = malloc ( sizeof( char* ) * ( nb_arg + 1) );
argv = bind->msgargs;
@@ -110,8 +111,8 @@ static IvyBinding IvyBindingCompileRegexp( IvyBindingType typ, const char * expr
if ( regexp != NULL )
{
bind = (IvyBinding)malloc( sizeof( struct _binding ));
+ memset( bind, 0, sizeof(*bind ) );
bind->regexp = regexp;
- bind->next = NULL;
bind->type = IvyBindRegexp;
bind->inspect = pcre_study(regexp,0,&err_buf);
if (err_buf!=NULL)
@@ -130,6 +131,7 @@ static IvyBinding IvyBindingCompileRegexp( IvyBindingType typ, const char * expr
if ( reg == 0 )
{
bind = (IvyBinding)malloc( sizeof( struct _binding ));
+ memset( bind, 0, sizeof(*bind ) );
bind->regexp = regexp;
bind->next = NULL;
}
@@ -161,6 +163,10 @@ void IvyBindingFree( IvyBinding bind )
pcre_free(bind->regexp);
#else
#endif
+ if (bind->msgname)
+ free ( bind->msgname );
+ if (bind->msgargs)
+ free ( bind->msgargs );
free ( bind );
}
int IvyBindingExecRegexp( IvyBinding bind, const char * message )