Surface creation fails in SDL 1.2.8 if width or height is larger than 16384 (works fine in 1.2.7)

Subject says it all, really. The problem is in SDL_CreateRGBSurface
(snip from SDL 1.2.8 source):

— 8< —
/* Make sure the size requested doesn’t overflow our datatypes /
/
Next time I write a library like SDL, I’ll use int for size.
:slight_smile: */
if ( width > 16384 || height > 16384 ) {
SDL_SetError(“Width or height is too large”);
return(NULL);
}
— 8< —

I can understand why there’s a limit for the width (the 16-bit surface
pitch could overflow), but why is the height limit so low ? This breaks
a game I’m working on (I’m the Linux porter of Deadly Rooms Of Death;
the new version uses a surface of height 27302). As I said in the
subject, it worked without any trouble with SDL 1.2.7.

By the way, shouldn’t the width limit in the if above be “> 16383” ?
16384 * 4 = 65536 -> pitch = 0… Also, I think it could be increased
if the bpp is lower than 32, at least for software surfaces.

  • Gerry
    if ( width > 16384 || height > 16384 ) {

In CVS, I changed this line to:
if ( width >= 16384 || height >= 65536 ) {

BTW, in SDL 1.3 this will go away.

See ya!
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Sam Lantinga wrote:

In CVS, I changed this line to:
if ( width >= 16384 || height >= 65536 ) {

Great! Thank you!

BTW, in SDL 1.3 this will go away.

\o/

  • Gerry