# I applied a patch to fix all the list \*\_free functions

**URL:** <https://www.ruby-forum.com/t/i-applied-a-patch-to-fix-all-the-list-free-functions/192101>\
**Category:** Ruby-Gnome 2\
**Created:** [July 23, 2010, 6:55pm UTC](https://www.ruby-forum.com/t/i-applied-a-patch-to-fix-all-the-list-free-functions/192101 "2010-07-23T18:55:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [July 23, 2010, 6:55pm UTC](https://www.ruby-forum.com/t/i-applied-a-patch-to-fix-all-the-list-free-functions/192101/1 "2010-07-23T18:55:56Z")

</div>

I applied a patch to fix all the list \*\_free functions.

These functions were horribly broken. Not only could they fail to  
release the memory if an error occurred, they never actually freed the  
memory even if everything succeeded! The argument variable was  
reused, so when, for example, g\_list\_free was actually called, the  
argument would be NULL.

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [July 24, 2010, 1:39am UTC](https://www.ruby-forum.com/t/i-applied-a-patch-to-fix-all-the-list-free-functions/192101/2 "2010-07-24T01:39:53Z")

</div>

Hi,

In [AANLkTi=3H=0rkGbOcwR1=removed\_email\_address@domain.invalid](mailto:AANLkTi=3H=0rkGbOcwR1=removed_email_address@domain.invalid)  
“[ruby-gnome2-devel-en] I applied a patch to fix all the list \*\_free  
functions” on Fri, 23 Jul 2010 18:55:03 +0200,  
Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I applied a patch to fix all the list \*\_free functions.
> 
> These functions were horribly broken. Not only could they fail to  
> release the memory if an error occurred, they never actually freed the  
> memory even if everything succeeded! The argument variable was  
> reused, so when, for example, g\_list\_free was actually called, the  
> argument would be NULL.

It seems that rbgutil\_glist2ary\_string\_and\_free() doesn’t  
free list data when it gets an error while processing.

e.g.:

list: (“a”, “b”, “c”)  
error on “b”:  
\* “c” will not be freed. (“b” may not be freed?)  
\* list will be freed.

## Thanks,

kou

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [July 24, 2010, 10:40am UTC](https://www.ruby-forum.com/t/i-applied-a-patch-to-fix-all-the-list-free-functions/192101/3 "2010-07-24T10:40:39Z")

</div>

On Sat, Jul 24, 2010 at 01:39, Kouhei S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Â Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > These functions were horribly broken. Â Not only could they fail to  
> > release the memory if an error occurred, they never actually freed the  
> > memory even if everything succeeded! Â The argument variable was  
> > reused, so when, for example, g\_list\_free was actually called, the  
> > argument would be NULL.
> 
> It seems that rbgutil\_glist2ary\_string\_and\_free() doesn’t  
> free list data when it gets an error while processing.

Youâ€™re correct. Iâ€™ve committed a fix. Thanks!

---

<div class="post-metadata">

**Author:** ![Nikolai\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/df705f/32.png) [@Nikolai\_W](https://www.ruby-forum.com/u/Nikolai_W)\
**Post date:** [July 25, 2010, 5:00am UTC](https://www.ruby-forum.com/t/i-applied-a-patch-to-fix-all-the-list-free-functions/192101/4 "2010-07-25T05:00:31Z")

</div>

Hi,

In [AANLkTinrcf2y=removed\_email\_address@domain.invalid](mailto:AANLkTinrcf2y=removed_email_address@domain.invalid)  
“Re: [ruby-gnome2-devel-en] I applied a patch to fix all the list  
\*\_free functions” on Sat, 24 Jul 2010 10:39:55 +0200,  
Nikolai W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > It seems that rbgutil\_glist2ary\_string\_and\_free() doesn’t  
> > free list data when it gets an error while processing.
> 
> You¢re correct. I¢ve committed a fix. Thanks!

## Thanks!

kou
