Welcome! Log In Create A New Profile

Advanced

Re: [patch] ngx_array zero capacity support

Peter Schüller
September 11, 2009 05:28PM
Hello,

>> attached is a patch to make the ngx_array_push() support zero-capacity
>> arrays. Previously it would fail to grow the data buffer correctly (2
>> * 0 = 0).
>
> Could you please provide a use case where one should create array
> without elements allocated?

Not necessarily (I can dream up scenarios, but that doesn't matter);
my phrasing in the original post was perhaps a bit misleading.

We had a case of this by accident and while debugging the resulting
problems realized that the array push gave us an invalid pointer. We
do not "need" this particular use case to be supported. However even
so, silently accepting the request and causing memory corruption is
IMO a bug. The request should either be serviced correctly, or an
error should be indicated.

> Current nginx coding style suggest that arrays aren't created
> until needed, and initial allocation chunk must be at least 1.

Sure, which is what we do now and intended to do

An alternative fix is to just translate requests for arrays of
capacity 0 to be of capacity 1. And yet another is to fail the call.

--
/ Peter Schuller aka scode
Subject Author Posted

[patch] ngx_array zero capacity support

Peter Schüller September 11, 2009 10:48AM

Re: [patch] ngx_array zero capacity support

Maxim Dounin September 11, 2009 01:10PM

Re: [patch] ngx_array zero capacity support

Peter Schüller September 11, 2009 05:28PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 307
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready