# HG changeset patch # User Matti Hamalainen # Date 1188778865 0 # Node ID 11e24183ff23c954ea04f7ed1a790bf479b15737 # Parent 0f2b7b2556ff78ccda7aee4491f45618fa40d81c Properly initialize xs_cfg struct; Check for 0 in sid2NFilterPresets. diff -r 0f2b7b2556ff -r 11e24183ff23 src/xs_config.c --- a/src/xs_config.c Sun Sep 02 23:09:05 2007 +0000 +++ b/src/xs_config.c Mon Sep 03 00:21:05 2007 +0000 @@ -208,6 +208,8 @@ XSDEBUG("initializing configuration ...\n"); XS_MUTEX_LOCK(xs_cfg); + xs_memset(&xs_cfg, 0, sizeof(xs_cfg)); + /* Initialize values with sensible defaults */ xs_cfg.audioBitsPerSample = XS_RES_16BIT; xs_cfg.audioChannels = XS_CHN_MONO; @@ -238,6 +240,8 @@ xs_cfg.forceSpeed = FALSE; xs_cfg.sid2OptLevel = 0; + xs_cfg.sid2NFilterPresets = 0; + #ifdef HAVE_RESID_BUILDER xs_cfg.sid2Builder = XS_BLD_RESID; #else @@ -567,13 +571,15 @@ /* Filters and presets are a special case */ xs_filter_load_into(cfg, 0, &xs_cfg.sid2Filter); - xs_cfg.sid2FilterPresets = g_malloc0(xs_cfg.sid2NFilterPresets * sizeof(t_xs_sid2_filter *)); - if (!xs_cfg.sid2FilterPresets) { - xs_error(_("Allocation of sid2FilterPresets structure failed!\n")); - } else { - for (i = 0; i < xs_cfg.sid2NFilterPresets; i++) { - xs_cfg.sid2FilterPresets[i] = - xs_filter_load(cfg, i); + + if (xs_cfg.sid2NFilterPresets > 0) { + xs_cfg.sid2FilterPresets = g_malloc0(xs_cfg.sid2NFilterPresets * sizeof(t_xs_sid2_filter *)); + if (!xs_cfg.sid2FilterPresets) { + xs_error(_("Allocation of sid2FilterPresets structure failed!\n")); + } else { + for (i = 0; i < xs_cfg.sid2NFilterPresets; i++) { + xs_cfg.sid2FilterPresets[i] = xs_filter_load(cfg, i); + } } }