POV-Ray : Newsgroups : povray.programming : Segfault due to short int overflow at bbox.cpp:596 Server Time
22 Dec 2024 07:39:08 EST (-0500)
  Segfault due to short int overflow at bbox.cpp:596 (Message 1 to 2 of 2)  
From: Eric Buddington
Subject: Segfault due to short int overflow at bbox.cpp:596
Date: 27 Dec 2005 00:00:01
Message: <web.43b0c972a307566187938cd40@news.povray.org>
POV-Ray 3.6.1
bbox.cpp:596

If there are too many (>32k) infinite objects, the short int index 'i'
overflows
and attempts to reference Infinite[-32767], which naturally spews core.

I suggest throwing an error in the case of overflow, and perhaps bumping up
'i' to an unsigned int, if there's any sane scene that uses 32k infinite
objects.

Less critically, I'd suggest moving the declaration of 'i' to the top of the
block enclosing the 'for' loop, or into the 'for' loop itself. It would
make the code a little easier to read, though I don't know what your coding
standards are.

-Eric


Post a reply to this message

From: Christoph Hormann
Subject: Re: Segfault due to short int overflow at bbox.cpp:596
Date: 29 Dec 2005 11:40:04
Message: <dp1384$ltk$1@chho.imagico.de>
Eric Buddington wrote:
> POV-Ray 3.6.1
> bbox.cpp:596
> 
> If there are too many (>32k) infinite objects, the short int index 'i'
> overflows
> and attempts to reference Infinite[-32767], which naturally spews core.
> 
> I suggest throwing an error in the case of overflow, and perhaps bumping up
> 'i' to an unsigned int, if there's any sane scene that uses 32k infinite
> objects.

Seems correct although to be consistent with other places 
(Build_Bounding_Slabs) you should use 'long'.

> Less critically, I'd suggest moving the declaration of 'i' to the top of the
> block enclosing the 'for' loop, or into the 'for' loop itself. It would
> make the code a little easier to read, though I don't know what your coding
> standards are.

This code is quite old so the declarations obey older restrictions.

Christoph

-- 
POV-Ray tutorials, include files, Landscape of the week:
http://www.imagico.de/ (Last updated 31 Oct. 2005)
MegaPOV with mechanics simulation: http://megapov.inetart.net/


Post a reply to this message

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