Permalink
Browse files

"Memory leak. Dynamic memory stored in 'entry' allocated through

function 'get_by_mime_or_new' at line 125 is lost at line 126"
(Klocwork.com Issue #89)

git-svn-id: svn://cherokee-project.com/cherokee/trunk@6703 5dc97367-97f1-0310-9951-d761b3857238
  • Loading branch information...
1 parent 37d5498 commit adb3d07fc1f4e6d06d21b8d9814e3a893c8725da @alobbs alobbs committed May 23, 2011
Showing with 12 additions and 3 deletions.
  1. +12 −3 cherokee/mime.c
View
@@ -56,7 +56,7 @@ cherokee_mime_free (cherokee_mime_t *mime)
if (mime == NULL)
return ret_ok;
- cherokee_avl_mrproper (&mime->ext_table, NULL);
+ cherokee_avl_mrproper (AVL_GENERIC(&mime->ext_table), NULL);
list_for_each_safe (i, tmp, &mime->entry_list) {
cherokee_list_del (i);
@@ -95,15 +95,24 @@ get_by_mime_or_new (cherokee_mime_t *mime, cherokee_buffer_t *type, cherokee_mim
{
ret_t ret;
+ /* Hit
+ */
ret = get_by_mime (mime, type, entry);
if (ret == ret_ok)
return ret_ok;
+ /* Miss
+ */
ret = cherokee_mime_entry_new (entry);
- if (ret != ret_ok) return ret;
+ if (ret != ret_ok) {
+ return ret;
+ }
ret = cherokee_mime_entry_set_type (*entry, type);
- if (ret != ret_ok) return ret;
+ if (ret != ret_ok) {
+ cherokee_mime_entry_free (*entry);
+ return ret;
+ }
cherokee_list_add (LIST(*entry), &mime->entry_list);

0 comments on commit adb3d07

Please sign in to comment.