On Fri, Feb 14, 2020 at 11:33:50AM +0100, Ruediger Pluem wrote:
> On 02/14/2020 10:08 AM, Joe Orton wrote:
> > I've been playing with UBSan[1] which catches undefined behaviour, found a 
> > couple of interesting things so far.
> > 
> > One is with event, I messed with the line numbers but the error is:
> > 
> > event.c:3620:13: runtime error: null pointer passed as argument 2, which is 
> > declared to never be null
> > 
> > from the memcpy() in this code: 
> > https://github.com/apache/httpd/blob/trunk/server/mpm/event/event.c#L3619
> > 
> >         new_ptr = (int *)apr_palloc(ap_pglobal, new_max * sizeof(int));
> >         memcpy(new_ptr, retained->idle_spawn_rate,
> >                retained->mpm->num_buckets * sizeof(int));
> 
> I guess the above only does not crash because retained->mpm->num_buckets is 0 
> at the same time.
> But this is probably something we should not rely on with all memcpy 
> implementations.

Ahhhh, yes, that makes more sense now.  Thanks a lot.

...
> I guess there is no need for two cases here. We should only avoid the call to 
> memcpy
> if retained->idle_spawn_rate is NULL. The initialization happens then in the 
> block starting
> at line 3624.

Gotcha.  Done in r1874011.

Regards, Joe

Reply via email to