Re: Memory problems with g_list_append()
- From: Sven Neumann <sven gimp org>
- To: Jeff Shipman - SysProg <jeff nmt edu>
- Cc: gtk-list gtk org
- Subject: Re: Memory problems with g_list_append()
- Date: 29 Jan 2002 22:56:57 +0100
Hi,
Jeff Shipman - SysProg <jeff nmt edu> writes:
> I have a situation where I build a list of
> valid shells (from /etc/shells) with one
> function and then compare a user's shell with
> that list using another function to determine
> if the user has a valid shell. However, I'm
> running into a problem of corrupted data when
> I try to actually check the shell.
>
> In util.c here are my build and check functions:
>
> -- BEGIN --
> static GList *valid_shells = NULL;
>
> /*
> ** build_valid_shells - Builds a list of all
> ** shells valid for users.
> */
> void build_valid_shells()
> {
> gchar *shell;
> GList *shells;
>
> setusershell();
> while((shell = getusershell()) != NULL)
> valid_shells = g_list_append(valid_shells, shell);
Unless getusershell() returns a copied version (which I doubt
it does) you need to insert the g_strdup'ed value of shell
into your list.
Salut, Sven
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]