Re: g_strstrip(" ") segfaulting?



Daniel,

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).

Cheers,
    Leandro



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]