Changeset: 3337614246d6 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3337614246d6
Modified Files:
        clients/mapiclient/mclient.c
        common/stream/stream.c
Branch: Jun2016
Log Message:

Memory leaks.


diffs (73 lines):

diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -1995,6 +1995,8 @@ doFileBulk(Mapi mid, stream *fp)
        buf = malloc(bufsize + 1);
        if (!buf) {
                fprintf(stderr, "cannot allocate memory for send buffer\n");
+               if (fp)
+                       close_stream(fp);
                return 1;
        }
 
@@ -2067,6 +2069,8 @@ doFileBulk(Mapi mid, stream *fp)
 
        free(buf);
        mnstr_flush(toConsole);
+       if (fp)
+               close_stream(fp);
        return errseen;
 }
 
@@ -2637,11 +2641,12 @@ doFile(Mapi mid, stream *fp, int useinse
                                         * convert filename from UTF-8
                                         * to locale */
                                        if ((s = open_rastream(line)) == NULL ||
-                                           mnstr_errnr(s))
+                                           mnstr_errnr(s)) {
+                                               if (s)
+                                                       close_stream(s);
                                                fprintf(stderr, "%s: cannot 
open\n", line);
-                                       else
+                                       } else
                                                doFile(mid, s, 0, 0, 0);
-                                       close_stream(s);
                                        continue;
                                }
                                case '>':
@@ -2832,6 +2837,7 @@ doFile(Mapi mid, stream *fp, int useinse
        if (prompt)
                deinit_readline();
 #endif
+       close_stream(fp);
        return errseen;
 }
 
@@ -3391,7 +3397,6 @@ main(int argc, char **argv)
                                c |= 1;
                        } else {
                                c |= doFile(mid, s, useinserts, interactive, 
save_history);
-                               close_stream(s);
                        }
                        fp = NULL;
                        optind++;
@@ -3402,7 +3407,6 @@ main(int argc, char **argv)
        if (!has_fileargs && command == NULL) {
                stream *s = file_rastream(stdin, "<stdin>");
                c = doFile(mid, s, useinserts, interactive, save_history);
-               mnstr_destroy(s);
        }
 
        mapi_destroy(mid);
diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -4575,6 +4575,8 @@ cb_destroy(stream *s)
 
        if (cb->destroy)
                (*cb->destroy)(cb->private);
+       free(cb);
+       s->stream_data.p = NULL;
        destroy(s);
 }
 
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to