ExternalArray>>keysAndValuesDo: bounds checking

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

ExternalArray>>keysAndValuesDo: bounds checking

Chris Uppal-3
Shouldn't ExternalArray>>keysAndValuesDo: check its bounds before iterating ?
I've just noticed that I can iterate off into never-never land by providing
out-of-bounds start/stop indexes.

Or is ExternalArray not supposed to do any bounds checking ?

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: ExternalArray>>keysAndValuesDo: bounds checking

Chris Uppal-3
Blast!  I wrote:

> Shouldn't ExternalArray>>keysAndValuesDo: check its bounds before

Make that ExternalArray>>from:to:keysAndValuesDo:

Sorry.

    -- chris


Reply | Threaded
Open this post in threaded view
|

Re: ExternalArray>>keysAndValuesDo: bounds checking

Blair McGlashan
In reply to this post by Chris Uppal-3
"Chris Uppal" <[hidden email]> wrote in message
news:3f98fe05$0$113$[hidden email]...
> Shouldn't ExternalArray>>keysAndValuesDo: check its bounds before
iterating ?
> I've just noticed that I can iterate off into never-never land by
providing
> out-of-bounds start/stop indexes.

Yes, it is. Out-of-bounds access would be caught by the underlying
collection in the case of internal buffers (i.e. it contains a ByteArray),
but not when the ExternalArray is a reference (i.e. it contains an
ExternalAddress). The same applies to ExternalArray>>at: and #at:put:. This
is already patched in PL2 which I am hoping to release in beta later today.
Of course it is still possible to write outside the bounds of an
by-reference buffer if one sets up the length wrongly, but I'm afraid that
is unavoidable.

Regards

Blair