Changeset: ff63f6342e2f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ff63f6342e2f
Modified Files:
        clients/mapiclient/mclient.c
        monetdb5/modules/mal/pcre.c
Branch: Jun2016
Log Message:

Memory leaks.


diffs (110 lines):

diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -3322,6 +3322,7 @@ main(int argc, char **argv)
        if (command != NULL) {
 #ifdef HAVE_ICONV
                iconv_t cd_in;
+               int free_command = 0;
 
                if (encoding != NULL &&
                    (cd_in = iconv_open("utf-8", encoding)) != (iconv_t) -1) {
@@ -3331,6 +3332,7 @@ main(int argc, char **argv)
                        int factor = 4;
                        size_t tolen = factor * fromlen + 1;
                        char *to = malloc(tolen);
+                       free_command = 1;
 
                  try_again:
                        command = to;
@@ -3367,6 +3369,10 @@ main(int argc, char **argv)
                timerStart();
                c = doRequest(mid, command);
                timerEnd();
+#ifdef HAVE_ICONV
+               if (free_command)
+                       free(command);
+#endif
        }
 
        if (optind < argc) {
diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -318,14 +318,14 @@ pcre_likesubselect(BAT **bnp, BAT *b, BA
        pe = pcre_study(re, 0, &error);
        if (error != NULL) {
                my_pcre_free(re);
-               my_pcre_free(pe);
+               pcre_free_study(pe);
                throw(MAL, "pcre.likesubselect",
                          OPERATION_FAILED ": studying pattern \"%s\" 
failed\n", pat);
        }
        bn = BATnew(TYPE_void, TYPE_oid, s ? BATcount(s) : BATcount(b), 
TRANSIENT);
        if (bn == NULL) {
                my_pcre_free(re);
-               my_pcre_free(pe);
+               pcre_free_study(pe);
                throw(MAL, "pcre.likesubselect", MAL_MALLOC_FAIL);
        }
        off = b->hseqbase - BUNfirst(b);
@@ -373,7 +373,7 @@ pcre_likesubselect(BAT **bnp, BAT *b, BA
                                pcre_exec(re, pe, v, (int) strlen(v), 0, 0, 
ovector, 10) >= 0);
        }
        my_pcre_free(re);
-       my_pcre_free(pe);
+       pcre_free_study(pe);
        bn->tsorted = 1;
        bn->trevsorted = bn->batCount <= 1;
        bn->tkey = 1;
@@ -391,7 +391,7 @@ pcre_likesubselect(BAT **bnp, BAT *b, BA
   bunins_failed:
        BBPreclaim(bn);
        my_pcre_free(re);
-       my_pcre_free(pe);
+       pcre_free_study(pe);
        *bnp = NULL;
        throw(MAL, "pcre.likesubselect", OPERATION_FAILED);
 }
@@ -567,6 +567,7 @@ pcre_replace(str *res, const char *origi
                        offset = ovector[1];
                }
        } while((j > 0) && (offset < len_origin_str) && (ncaptures < 
MAX_NR_CAPTURES));
+       pcre_free_study(extra);
 
        if (ncaptures > 0){
                tmpres = GDKmalloc(len_origin_str - len_del + (len_replacement 
* ncaptures) + 1);
@@ -688,6 +689,7 @@ pcre_replace_bat(BAT **res, BAT *origin_
                        replaced_str = GDKmalloc(len_origin_str - len_del + 
(len_replacement * ncaptures) + 1);
                        if (!replaced_str) {
                                my_pcre_free(pcre_code);
+                               pcre_free_study(extra);
                                GDKfree(ovector);
                                throw(MAL, "pcre_replace_bat", MAL_MALLOC_FAIL);
                        }
@@ -725,6 +727,7 @@ pcre_replace_bat(BAT **res, BAT *origin_
                }
        }
 
+       pcre_free_study(extra);
        my_pcre_free(pcre_code);
        GDKfree(ovector);
        BATseqbase(tmpbat, origin_strs->hseqbase);
@@ -1576,7 +1579,7 @@ pcresubjoin(BAT *r1, BAT *r2, BAT *l, BA
                }
                if (pcrere) {
                        my_pcre_free(pcrere);
-                       my_pcre_free(pcreex);
+                       pcre_free_study(pcreex);
                        pcrere = NULL;
                        pcreex = NULL;
                }
@@ -1618,7 +1621,7 @@ pcresubjoin(BAT *r1, BAT *r2, BAT *l, BA
        if (pcrere)
                my_pcre_free(pcrere);
        if (pcreex)
-               my_pcre_free(pcreex);
+               pcre_free_study(pcreex);
        assert(msg != MAL_SUCCEED);
        return msg;
 }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to