confuse-devel
[Top][All Lists]
Advanced

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

[Confuse-devel] confuse bug ?


From: Priyank
Subject: [Confuse-devel] confuse bug ?
Date: Fri, 3 Nov 2006 11:24:07 +0530


Hi,
i've been experiencing a small problem with libconfuse-2.5
My app just crashes on cfg_parse() with a segmentation fault. heres the code that crashes

typedef struct
{
    int systray_enable;
    int port;
    char *hostname;
    char *password;
} Conf;

Conf *
gimmix_config_init (void)
{
    cfg_t     *cfg;
    Conf     *conf;
    int          ret;
   
    conf = (Conf*)malloc(sizeof(Conf));
   
    cfg_opt_t opts[] = {
        CFG_SIMPLE_STR ("mpd_hostname", &conf->hostname),
        CFG_SIMPLE_INT ("mpd_port", &conf->port),
        CFG_SIMPLE_STR ("mpd_password", &conf->password),
        CFG_SIMPLE_INT ("enable_systray", &conf->systray_enable),
        CFG_END()
    };
   
    cfg = cfg_init (opts, 0);
    ret = cfg_parse (cfg, "~/.gimmixrc");
   
    if (ret == CFG_PARSE_ERROR)
    {
        free (conf);
        return NULL;
    }

    if (!conf->hostname)
        conf->hostname = NULL;
       
    if (!conf->port)
        conf->port = 0;
   
    if ((conf->systray_enable != 0) && (conf->systray_enable != 1))
        conf->systray_enable = -1;
   
    /* Free the memory */
    cfg_free_value (opts);
   
    if (cfg)
        cfg_free (cfg);
   
    return conf;
}

Can you provide me any help  or is there a bug in my code ? I've tested this on x86_64 and there too, i have random crashes at the same cfg_parse ()

My sytem is Linux-2.6.18.1
gcc 4.1.1
glibc 2.5

Thanks.
--
Thou shalt never follow a null pointer, for at its end, madness and chaos lie !

Priyank M. Gosalia
Member of the Frugalware Linux Developer Team
reply via email to

[Prev in Thread] Current Thread [Next in Thread]