Changeset: 15cbcf0c79ac for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/15cbcf0c79ac
Modified Files:
        monetdb5/modules/mal/txtsim.c
Branch: Jul2021
Log Message:

Don't leak on error


diffs (26 lines):

diff --git a/monetdb5/modules/mal/txtsim.c b/monetdb5/modules/mal/txtsim.c
--- a/monetdb5/modules/mal/txtsim.c
+++ b/monetdb5/modules/mal/txtsim.c
@@ -271,6 +271,8 @@ soundex_code(char *Name, char *Key)
 static str
 soundex_impl(str *res, str *Name)
 {
+       str msg = MAL_SUCCEED;
+
        GDKfree(*res);
        RETURN_NIL_IF(strNil(*Name), TYPE_str);
 
@@ -279,7 +281,12 @@ soundex_impl(str *res, str *Name)
                throw(MAL,"soundex", SQLSTATE(HY013) MAL_MALLOC_FAIL);
 
        /* calculate Key for Name */
-       return soundex_code(*Name, *res);
+       if ((msg = soundex_code(*Name, *res))) {
+               GDKfree(*res);
+               *res = NULL;
+               return msg;
+       }
+       return msg;
 }
 
 static str
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to