POV-Ray : Newsgroups : povray.off-topic : update, updates, updates : Re: update, updates, updates Server Time
29 Jul 2024 02:31:09 EDT (-0400)
  Re: update, updates, updates  
From: scott
Date: 21 Jan 2013 03:23:24
Message: <50fcfafc$1@news.povray.org>
> The only situation that I can think of where an out-of-bounds access will
> probably happen is if pointers (and thus array indices) are 64-bit but
> the array size is wrongly a signed (32-bit) int. It then gets expanded
> to 64-bit when indexing the array, and ends up truly at negative addresses
> (from the array's start.)

You could also have the situation where the code is inconsistent 
regarding signed and unsigned (32-bit) values. Couldn't something like 
this break with a negative value of imageSize stored in the image file?

void LoadImageFromFile(unsigned int size);
void ReserveMemory(int size);

int headerSize = 1024;
int imageSize = readIntFromFile();
ReserveMemory(headerSize + imageSize);
LoadHeaderFromFile(headerSize);
LoadImageFromFile(imageSize);


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.