From 5c793cb420f8ee63d803cfc9de2453e42f703ed5 Mon Sep 17 00:00:00 2001 From: "srinivasa.m" Date: Thu, 27 Feb 2020 15:18:31 +0530 Subject: [PATCH] memory leak and missing error check issues fix Change-Id: I72660a30d7efdcf8a6a090eda76862d841145248 Signed-off-by: srinivasa.m --- server/fido_app_id_handler.c | 9 +++++++-- server/fido_server.c | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/server/fido_app_id_handler.c b/server/fido_app_id_handler.c index c9cf93a..524d17a 100755 --- a/server/fido_app_id_handler.c +++ b/server/fido_app_id_handler.c @@ -327,11 +327,16 @@ __b64_encode(unsigned char *input, int ip_len) RET_IF_FAIL(input != NULL, NULL); RET_IF_FAIL(ip_len > 0, NULL); - unsigned char *output = calloc(ip_len * 1.5, sizeof(char)); - + unsigned char *output = NULL; BIO *bmem = NULL; BIO *b64 = NULL; BUF_MEM *bptr = NULL; + + output = calloc(ip_len * 1.5, sizeof(char)); + if (output == NULL) { + _ERR("memory allocation failed \n"); + return NULL; + } b64 = BIO_new(BIO_f_base64()); if (b64 == NULL) { _ERR("BIO_new failed \n"); diff --git a/server/fido_server.c b/server/fido_server.c index d872905..6f41dc0 100755 --- a/server/fido_server.c +++ b/server/fido_server.c @@ -547,6 +547,8 @@ __copy_convert_uaf_trans_list(GList *uaf_tr_list) if (uaf_tr->display_charac != NULL) { asm_tr->display_charac = calloc(1, sizeof(_fido_asm_display_png_characteristics_descriptor_t)); if (asm_tr->display_charac == NULL) { + SAFE_DELETE(asm_tr->content); + SAFE_DELETE(asm_tr->content_type); SAFE_DELETE(asm_tr); return NULL; } @@ -566,6 +568,8 @@ __copy_convert_uaf_trans_list(GList *uaf_tr_list) fido_rgb_pallette_entry_s *asm_plte_entry = calloc(1, sizeof(fido_rgb_pallette_entry_s)); if (asm_plte_entry == NULL) { + SAFE_DELETE(asm_tr->content); + SAFE_DELETE(asm_tr->content_type); SAFE_DELETE(asm_tr->display_charac); SAFE_DELETE(asm_tr); return NULL; -- 2.7.4