David,
David Wortham wrote:
As I suspected, the lines causing the segfault are similar to:
// dir_cfg contains mostly ints
struct intContainer
{
int x
} intContainer;
/* ... later... in the merge function */
static void* dir_cfg_merge_function (apr_pool_t* the_pool, void*
the_parent_dir_cfg, void* the_sub_dir_cfg)
{
intContainer* merged_dir_cfg = apr_pcalloc(p, 1*sizeof(intContainer));
int y = 1;
The apr_pcalloc call should NOT fail unless you are really really tight
on memory or you're doing something pathological to that pool. Unless
intContainer is unearthly huge (and I doubt it is), this should never
fail... but, to be on the safe side, how about something like:
if (! (merged_dir_cfg)) // we assume ! NULL == true, safe if not "proper"
{ ap_log_error (....., "couldn't allocate memory for merged_dir_cfg); }
else {
merged_dir_cfg->x = y; // this line causes a segfault... why?
// this line would also segfault:
memcpy(, , 1*sizeof(int));
}
return merged_dir_cfg;
}
- Todd