From 83f80ad4961df2d00d9c9b7987b4f1b6f55aa21f Mon Sep 17 00:00:00 2001 From: Tonton Th Date: Sun, 3 Mar 2019 18:07:20 +0100 Subject: [PATCH] better error control in fimg_destroy --- lib/fimg-core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/fimg-core.c b/lib/fimg-core.c index 0e24dce..325ff63 100644 --- a/lib/fimg-core.c +++ b/lib/fimg-core.c @@ -106,7 +106,6 @@ return 0; } /* --------------------------------------------------------------------- */ - int fimg_destroy(FloatImg *fimg) { @@ -114,10 +113,18 @@ int fimg_destroy(FloatImg *fimg) fprintf(stderr, ">>> %-25s ( %p )\n", __func__, fimg); #endif +if (NULL == fimg) { + fprintf(stderr, "%s : parameter is null\n", __func__); + return -1; + } + if ( ! fimg_type_is_valid(fimg->type) ) { return -2; } - +if (NULL == fimg->R) { + fprintf(stderr, "%s : %p already freeed\n", __func__, fimg); + return -3; + } free(fimg->R); memset(fimg, 0, sizeof(FloatImg));