diff options
author | Jorge Arellano Cid <jcid@dillo.org> | 2009-05-08 16:39:19 -0400 |
---|---|---|
committer | Jorge Arellano Cid <jcid@dillo.org> | 2009-05-08 16:39:19 -0400 |
commit | c206e5e68a1e009df93cf9175d521a4c587158d1 (patch) | |
tree | 104c2e6611501b43e93acf1b65a7c3c8f18b6bd3 /src/dicache.c | |
parent | 7034881b87b53b087bae78aef8380e5258f68a24 (diff) |
Fix a memory leak when stopping an image-decoding process
Diffstat (limited to 'src/dicache.c')
-rw-r--r-- | src/dicache.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/dicache.c b/src/dicache.c index 6ffa6559..2e5a442b 100644 --- a/src/dicache.c +++ b/src/dicache.c @@ -175,7 +175,7 @@ static void Dicache_remove(const DilloUrl *Url, int version) { DICacheNode *node; DICacheEntry *entry, *prev; - + _MSG("Dicache_remove url=%s\n", URL_STR(Url)); node = dList_find_sorted(CachedIMGs, Url, Dicache_node_by_url_cmp); prev = entry = (node) ? node->first : NULL; @@ -185,10 +185,15 @@ static void Dicache_remove(const DilloUrl *Url, int version) } if (entry) { + _MSG("Dicache_remove Decoder=%p DecoderData=%p\n", + entry->Decoder, entry->DecoderData); /* Eliminate this dicache entry */ dFree(entry->cmap); a_Bitvec_free(entry->BitVec); a_Imgbuf_unref(entry->v_imgbuf); + if (entry->Decoder) { + entry->Decoder(CA_Abort, entry->DecoderData); + } dicache_size_total -= entry->TotalSize; if (node->first == entry) { @@ -208,12 +213,13 @@ static void Dicache_remove(const DilloUrl *Url, int version) /* * Unrefs the counter of a dicache entry, and _if_ no DwImage is acessing - * this buffer, then we call Dicache_free to do the dirty job. + * this buffer, then we call Dicache_remove() to do the job. */ void a_Dicache_unref(const DilloUrl *Url, int version) { DICacheEntry *entry; + _MSG("a_Dicache_unref\n"); if ((entry = a_Dicache_get_entry(Url, version))) { if (--entry->RefCount == 0) { Dicache_remove(Url, version); @@ -419,9 +425,10 @@ static void *Dicache_image(int ImgType, const char *MimeType, void *Ptr, /* Repeated image */ a_Dicache_ref(DicEntry->url, DicEntry->version); } - DicEntry->Decoder = (ImgType == DIC_Png) ? a_Png_callback : - (ImgType == DIC_Gif) ? a_Gif_callback : - (ImgType == DIC_Jpeg) ? a_Jpeg_callback : NULL; + DicEntry->Decoder = (ImgType == DIC_Png) ? (CA_Callback_t)a_Png_callback : + (ImgType == DIC_Gif) ? (CA_Callback_t)a_Gif_callback : + (ImgType == DIC_Jpeg) ? (CA_Callback_t)a_Jpeg_callback: + NULL; *Data = DicEntry->DecoderData; *Call = (CA_Callback_t) a_Dicache_callback; |