Possible leaks (MonetDB-11.37.7\common\stream\stream.c)
Possible leaks: MonetDB-11.37.7\common\stream\stream.
1. At line 1306 if (stream_bzread(s, buf, 1, UTF8BOMLENGTH) == UTF8BOMLENGTH && strncmp(buf, UTF8BOM, UTF8BOMLENGTH) == 0) { s->isutf8 = true; } else if (s->stream_data.p) { bzp = s->stream_data.p; BZ2_bzReadClose(&err, bzp->b); rewind(bzp->f); bzp->b = BZ2_bzReadOpen(&err, bzp->f, 0, 0, NULL, 0); }
If stream_bzread at line 1302 is successful, and (s->stream_data.p) is not null at line 1305, bzp (original pointer malloc) is not lost at line 1306? bzp = s->stream_data.p;
2. At line 1322: if (err != BZ_OK) { stream_bzclose(s); destroy(s); return NULL; }
miss free(bzp);? destroy(s) do not free bzp, according, with line 1283.
3. At line 2350 miss free(c);
regards, Ranier Vilela
I don't think there is a leak.
A little higher in the function, before all the conditions that you're looking at, there is the statement s->stream_data.p = (void *) bzp; so bzp is saved first and s->stream_data.p and bzp are actually the same pointer. I'm not sure why the assignment you're referring to since they are already the same. It could be historical, but I'd have to look at the logs.
On 03/08/2020 16.31, Ranier Vilela wrote:
Possible leaks: MonetDB-11.37.7\common\stream\stream.
- At line 1306
if (stream_bzread(s, buf, 1, UTF8BOMLENGTH) == UTF8BOMLENGTH && strncmp(buf, UTF8BOM, UTF8BOMLENGTH) == 0) { s->isutf8 = true; } else if (s->stream_data.p) { bzp = s->stream_data.p; BZ2_bzReadClose(&err, bzp->b); rewind(bzp->f); bzp->b = BZ2_bzReadOpen(&err, bzp->f, 0, 0, NULL, 0); }
If stream_bzread at line 1302 is successful, and (s->stream_data.p) is not null at line 1305, bzp (original pointer malloc) is not lost at line 1306? bzp = s->stream_data.p;
- At line 1322:
if (err != BZ_OK) { stream_bzclose(s); destroy(s); return NULL; }
miss free(bzp);? destroy(s) do not free bzp, according, with line 1283.
- At line 2350
miss free(c);
regards, Ranier Vilela
developers-list mailing list developers-list@monetdb.org https://www.monetdb.org/mailman/listinfo/developers-list
Em seg., 3 de ago. de 2020 às 12:47, Sjoerd Mullender sjoerd@monetdb.org escreveu:
I don't think there is a leak.
A little higher in the function, before all the conditions that you're looking at, there is the statement s->stream_data.p = (void *) bzp; so bzp is saved first and s->stream_data.p and bzp are actually the same pointer. I'm not sure why the assignment you're referring to since they are already the same. It could be historical, but I'd have to look at the logs.
And about 2 and 3?
regards, Ranier Vilela
On 04/08/2020 17.34, Ranier Vilela wrote:
Em seg., 3 de ago. de 2020 às 12:47, Sjoerd Mullender <sjoerd@monetdb.org mailto:sjoerd@monetdb.org> escreveu:
I don't think there is a leak. A little higher in the function, before all the conditions that you're looking at, there is the statement s->stream_data.p = (void *) bzp; so bzp is saved first and s->stream_data.p and bzp are actually the same pointer. I'm not sure why the assignment you're referring to since they are already the same. It could be historical, but I'd have to look at the logs.
And about 2 and 3?
About 2: The call to stream_bzclose calls free(s-stream_data.p) which is the same as bzp, so that gets freed.
About 3: c is assigned to s->stream_data.p about half way in the function. As long as s doesn't get freed without first freeing s->stream_data.p, we're good. And freeing s->stream_data.p happens in curl_destroy when that gets called.
regards, Ranier Vilela
developers-list mailing list developers-list@monetdb.org https://www.monetdb.org/mailman/listinfo/developers-list
Em ter., 4 de ago. de 2020 às 13:06, Sjoerd Mullender sjoerd@monetdb.org escreveu:
On 04/08/2020 17.34, Ranier Vilela wrote:
Em seg., 3 de ago. de 2020 às 12:47, Sjoerd Mullender <sjoerd@monetdb.org mailto:sjoerd@monetdb.org> escreveu:
I don't think there is a leak. A little higher in the function, before all the conditions that
you're
looking at, there is the statement s->stream_data.p = (void *) bzp; so bzp is saved first and s->stream_data.p and bzp are actually the
same
pointer. I'm not sure why the assignment you're referring to since they are already the same. It could be historical, but I'd have to look at the logs.
And about 2 and 3?
About 2: The call to stream_bzclose calls free(s-stream_data.p) which is the same as bzp, so that gets freed.
About 3: c is assigned to s->stream_data.p about half way in the function. As long as s doesn't get freed without first freeing s->stream_data.p, we're good. And freeing s->stream_data.p happens in curl_destroy when that gets called.
Nice, Thank you.
regards, Ranier Vilela
participants (2)
-
Ranier Vilela
-
Sjoerd Mullender