Changed to fix possible double-free bug under some circumstances.

git-svn-id: file:///home/mbr/svn/fwknop/trunk@210 510a4753-2344-4c79-9c09-4d669213fbeb
This commit is contained in:
Damien Stuart
2010-03-14 03:45:03 +00:00
parent f3c33c273b
commit 9282a0fd29
3 changed files with 10 additions and 3 deletions
+1
View File
@@ -184,6 +184,7 @@ fko_new_with_data(fko_ctx_t *r_ctx, char *enc_msg, char *dec_key)
if(res != FKO_SUCCESS)
{
fko_destroy(ctx);
*r_ctx = NULL; /* Make sure the caller ctx is null just in case */
return(res);
}
}
+1 -1
View File
@@ -80,7 +80,7 @@ typedef enum {
/* Macros used for determining ctx initialization state.
*/
#define CTX_INITIALIZED(ctx) (ctx->initval == FKO_CTX_INITIALIZED)
#define CTX_INITIALIZED(ctx) (ctx != NULL && ctx->initval == FKO_CTX_INITIALIZED)
#endif /* FKO_STATE_H */
+8 -2
View File
@@ -33,7 +33,11 @@
int
incoming_spa(fko_srv_options_t *opts)
{
fko_ctx_t ctx;
/* Always a good idea to initialize ctx to null if it will be used
* repeatedly (especially when using fko_new_with_data().
*/
fko_ctx_t ctx = NULL;
char *spa_ip_demark;
char spa_msg_src_ip[16];
char spa_msg_remain[1024]; /* --DSS should not have arbitrary limit */
@@ -372,7 +376,9 @@ display_ctx(ctx);
clean_and_bail:
fko_destroy(ctx);
if(ctx != NULL)
fko_destroy(ctx);
return(res);
}