Hi Colomban,
In tagmanager/read.c line 322 mio_new_memory is called without a free function. But I got lost in the multiple indirections trying to check if there is a default free function.
Otherwise it looks like this buffer may not be freed?
Cheers Lex
On 10/12/2011 10:43 PM, Lex Trotman wrote:
In tagmanager/read.c line 322 mio_new_memory is called without a free function. But I got lost in the multiple indirections trying to check if there is a default free function.
Otherwise it looks like this buffer may not be freed?
It seems to get allocated via tm_source_file.c:210 and freed through tm_source_file.c:220. bufferClose() is a macro for fileClose() and mio_free() seems to be called there (read.c:357).
Cheers, Matthew Brush
(sorry for the delay)
Le 13/10/2011 09:33, Matthew Brush a écrit :
On 10/12/2011 10:43 PM, Lex Trotman wrote:
In tagmanager/read.c line 322 mio_new_memory is called without a free function. But I got lost in the multiple indirections trying to check if there is a default free function.
Otherwise it looks like this buffer may not be freed?
It seems to get allocated via tm_source_file.c:210 and freed through tm_source_file.c:220. bufferClose() is a macro for fileClose() and mio_free() seems to be called there (read.c:357).
Exactly.
Actually there is no free function because the MIO object don't own the buffer, so it has no reason to free it. This is not really "good" in theory since the user must not free the buffer until the MIO created at this point is freed, but since the buffer isn't copied there's not really any other solution -- and copying it would be quite stupid IMO. And in practice, the code using bufferOpen() and bufferClose() is careful of not doing anything wrong, so it's OK.
Actually the buffer itself is allocated in document.c:2265 and freed two lines below.
Does it answer your question?
Cheers, Colomban
On 18 October 2011 03:47, Colomban Wendling lists.ban@herbesfolles.org wrote:
(sorry for the delay)
Le 13/10/2011 09:33, Matthew Brush a écrit :
On 10/12/2011 10:43 PM, Lex Trotman wrote:
In tagmanager/read.c line 322 mio_new_memory is called without a free function. But I got lost in the multiple indirections trying to check if there is a default free function.
Otherwise it looks like this buffer may not be freed?
It seems to get allocated via tm_source_file.c:210 and freed through tm_source_file.c:220. bufferClose() is a macro for fileClose() and mio_free() seems to be called there (read.c:357).
Exactly.
Yes, but with a NULL free parameter it doesn't free anything, but as you explain below, its not supposed to.
Cheers Lex
Actually there is no free function because the MIO object don't own the buffer, so it has no reason to free it. This is not really "good" in theory since the user must not free the buffer until the MIO created at this point is freed, but since the buffer isn't copied there's not really any other solution -- and copying it would be quite stupid IMO. And in practice, the code using bufferOpen() and bufferClose() is careful of not doing anything wrong, so it's OK.
Actually the buffer itself is allocated in document.c:2265 and freed two lines below.
Does it answer your question?
Cheers, Colomban _______________________________________________ Geany-devel mailing list Geany-devel@uvena.de https://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel