[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtk-app-devel
Subject:    Re: g_strstrip(" ") segfaulting?
From:       Daniel Leidert <daniel.leidert.spam () gmx ! net>
Date:       2010-05-08 23:22:54
Message-ID: 1273360974.5409.7.camel () haktar ! wgdd ! de
[Download RAW message or body]

Am Samstag, den 08.05.2010, 19:26 -0300 schrieb Leandro Pereira:
> On Sat, May 8, 2010 at 7:18 PM, Daniel Leidert
> <daniel.leidert.spam@gmx.net> wrote:
> > Is it the desired behavior, that
> >
> > g_strstrip(" ")
> >
> > leads to a segmentation fault? I would expect, that an empty string ("")
> > or NULL is returned.
> 
> The literal " " is a constant -- the operating system might allocate
> that to a read-only region. Since g_strstrip() modifies the string
> in-place, it isn't surprising that the program segfaults. If the
> string you'd like to work with g_strstrip() is a constant, you might
> consider using g_strdup() (and g_free() when you're done with it).

Argh. You are right. Thanks!

Regards, Daniel

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic