Skip to content

Commit

Permalink
Free strings returned from Glib so we don't leak memory.
Browse files Browse the repository at this point in the history
  • Loading branch information
Manfred committed Dec 30, 2008
1 parent 33e91d4 commit e23b461
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ext/glib/glib.c
Expand Up @@ -35,6 +35,7 @@ static VALUE utf8_upcase(VALUE self, VALUE string)
Check_Type(string, T_STRING);
temp = g_utf8_strup(StringValuePtr(string), RSTRING(string)->len);
result = rb_str_new2(temp);
free(temp);

return result;
}
Expand All @@ -55,6 +56,7 @@ static VALUE utf8_downcase(VALUE self, VALUE string)
Check_Type(string, T_STRING);
temp = g_utf8_strdown(StringValuePtr(string), RSTRING(string)->len);
result = rb_str_new2(temp);
free(temp);

return result;
}
Expand All @@ -75,6 +77,7 @@ static VALUE utf8_reverse(VALUE self, VALUE string)
Check_Type(string, T_STRING);
temp = g_utf8_strreverse(StringValuePtr(string), RSTRING(string)->len);
result = rb_str_new2(temp);
free(temp);

return result;
}
Expand Down Expand Up @@ -116,6 +119,7 @@ static VALUE utf8_normalize(VALUE self, VALUE string, VALUE form)

temp = g_utf8_normalize(StringValuePtr(string), RSTRING(string)->len, mode);
result = rb_str_new2(temp);
free(temp);

return result;
}
Expand Down

0 comments on commit e23b461

Please sign in to comment.