spritebuilder / SpriteBuilder

Objective-C Game Development Suite
http://www.spritebuilder.com/
Other
740 stars 292 forks source link

Project crashes in Tupac lib when "Trim sprites" is checked on specific sprite sheet #1275

Open LearnCocos2D opened 9 years ago

LearnCocos2D commented 9 years ago

This project here has a simple sprite sheet. It uses the Flappy Fly art pack so perhaps this can also be reproduced in an empty project containing this artwork in a sprite sheet folder

If you check the sprite sheet's "trim sprites" checkbox, the next publish crashes.

SB: develop from today. About box revision reads: 84e91bd92f

call stack:

Thread 35Queue : NSOperationQueue Serial Queue (serial)
#0  0x00000001001517d8 in +[Tupac trimmedRectForImage:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/libs/Tupac/Tupac.mm:128
#1  0x00000001001521c7 in -[Tupac createTextureAtlas] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/libs/Tupac/Tupac.mm:246
#2  0x000000010015779e in -[Tupac createTextureAtlasFromDirectoryPaths:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/libs/Tupac/Tupac.mm:624
#3  0x00000001001a6402 in -[PublishSpriteSheetOperation publishSpriteSheet] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/ccBuilder/PublishSpriteSheetOperation.m:73
#4  0x00000001001a5c37 in -[PublishSpriteSheetOperation main] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/ccBuilder/PublishSpriteSheetOperation.m:49

It crashes on this line:

            if (pixels[y*pixelsPerRow+x] & 0xff000000)

Looks like the resulting index 614,400 is out of bounds. According to w & h params (1280x1920) and considering UInt32 (4 bytes) the buffer must have 614,400 entries.

Full code for context, with x=320, y=1919, pixelsPerRow=320 at the time of crash:

    int x;
    for (x = 0; x < w; x++)
    {
        BOOL emptyRow = YES;
        for (int y = 0; y < h; y++)
        {
            if (pixels[y*pixelsPerRow+x] & 0xff000000)
            {
                emptyRow = NO;
            }
        }
        if (!emptyRow) break;
    }
LearnCocos2D commented 9 years ago

Note: This might be one of those rare situations where a certain combination of images triggers a publish crash that might also occur to some other users seemingly at random. So it's probably worth looking into even if it's just this project / this art pack.