From b5aec8419d853a70bf283a9755e647a316c0b7fd Mon Sep 17 00:00:00 2001 From: nishi Date: Sat, 27 Apr 2024 01:48:15 +0000 Subject: [PATCH] fix memory leak git-svn-id: file:///raid/svn-main/nishi-serenade/trunk@66 0f02c867-ac3d-714e-8a88-971ba1f6efcf --- Serenade/ffi_binding.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Serenade/ffi_binding.c b/Serenade/ffi_binding.c index bfa5dd0..13a8323 100644 --- a/Serenade/ffi_binding.c +++ b/Serenade/ffi_binding.c @@ -136,13 +136,16 @@ struct sn_generic* function_caller_handler(struct sn_interpreter* sn, int args, gen->string_length = strlen(gen->string); } - for(i = 0; fargs[i] != NULL; i++) { - if(strcmp(info->argtypes[i + 1], "string") == 0) { - free(*((void**)fargs[i])); - free(fargs[i]); + int i; + if(fargs != NULL){ + for(i = 0; i < info->argc; i++) { + if(strcmp(info->argtypes[i + 1], "string") == 0) { + free(*((void**)fargs[i])); + } + if(strcmp(info->argtypes[i + 1], "pointer") != 0) free(fargs[i]); } + free(fargs); } - if(fargs != NULL) free(fargs); return gen; } -- 2.43.0