[prev in list] [next in list] [prev in thread] [next in thread]
List: monetdb-checkins
Subject: MonetDB: Jun2016 - Memory leaks.
From: Sjoerd Mullender <commits+sjoerd=acm.org () monetdb ! org>
Date: 2016-06-30 20:29:39
Message-ID: hg.3337614246d6.1467318579.6315528441665844383 () monetdb2 ! cwi-incubator ! nl
[Download RAW message or body]
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
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic