{"action":"created","issue":{"url":"https://api.github.com/repos/spritebuilder/SpriteBuilder/issues/1275","labels_url":"https://api.github.com/repos/spritebuilder/SpriteBuilder/issues/1275/labels{/name}","comments_url":"https://api.github.com/repos/spritebuilder/SpriteBuilder/issues/1275/comments","events_url":"https://api.github.com/repos/spritebuilder/SpriteBuilder/issues/1275/events","html_url":"https://github.com/spritebuilder/SpriteBuilder/issues/1275","id":53554653,"number":1275,"title":"Project crashes in Tupac lib when \"Trim sprites\" is checked on specific sprite sheet","user":{"login":"LearnCocos2D","id":214599,"avatar_url":"https://avatars.githubusercontent.com/u/214599?v=3","gravatar_id":"","url":"https://api.github.com/users/LearnCocos2D","html_url":"https://github.com/LearnCocos2D","followers_url":"https://api.github.com/users/LearnCocos2D/followers","following_url":"https://api.github.com/users/LearnCocos2D/following{/other_user}","gists_url":"https://api.github.com/users/LearnCocos2D/gists{/gist_id}","starred_url":"https://api.github.com/users/LearnCocos2D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LearnCocos2D/subscriptions","organizations_url":"https://api.github.com/users/LearnCocos2D/orgs","repos_url":"https://api.github.com/users/LearnCocos2D/repos","events_url":"https://api.github.com/users/LearnCocos2D/events{/privacy}","received_events_url":"https://api.github.com/users/LearnCocos2D/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-06T19:46:55Z","updated_at":"2015-01-06T19:50:15Z","closed_at":null,"body":"[This project here](https://drive.google.com/a/apportable.com/folderview?id=0B0g1SgyD5RH2aXoxTzBiQUR6RTQ&usp=sharing) has a simple sprite sheet. It uses the [Flappy Fly art pack](https://s3.amazonaws.com/mgwu-misc/FlappyFlyArtPack.zip) so perhaps this can also be reproduced in an empty project containing this artwork in a sprite sheet folder \r\n\r\nIf you check the sprite sheet's \"trim sprites\" checkbox, the next publish crashes.\r\n\r\ncall stack:\r\n```\r\nThread 35Queue : NSOperationQueue Serial Queue (serial)\r\n#0\t0x00000001001517d8 in +[Tupac trimmedRectForImage:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/libs/Tupac/Tupac.mm:128\r\n#1\t0x00000001001521c7 in -[Tupac createTextureAtlas] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/libs/Tupac/Tupac.mm:246\r\n#2\t0x000000010015779e in -[Tupac createTextureAtlasFromDirectoryPaths:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/libs/Tupac/Tupac.mm:624\r\n#3\t0x00000001001a6402 in -[PublishSpriteSheetOperation publishSpriteSheet] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/ccBuilder/PublishSpriteSheetOperation.m:73\r\n#4\t0x00000001001a5c37 in -[PublishSpriteSheetOperation main] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/ccBuilder/PublishSpriteSheetOperation.m:49\r\n```\r\n\r\nIt crashes on this line:\r\n\r\n```\r\n            if (pixels[y*pixelsPerRow+x] & 0xff000000)\r\n```\r\n\r\nLooks 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.\r\n\r\nFull code for context, with x=320, y=1919, pixelsPerRow=320 at the time of crash:\r\n```\r\n    int x;\r\n    for (x = 0; x < w; x++)\r\n    {\r\n        BOOL emptyRow = YES;\r\n        for (int y = 0; y < h; y++)\r\n        {\r\n            if (pixels[y*pixelsPerRow+x] & 0xff000000)\r\n            {\r\n                emptyRow = NO;\r\n            }\r\n        }\r\n        if (!emptyRow) break;\r\n    }\r\n```"},"comment":{"url":"https://api.github.com/repos/spritebuilder/SpriteBuilder/issues/comments/68922447","html_url":"https://github.com/spritebuilder/SpriteBuilder/issues/1275#issuecomment-68922447","issue_url":"https://api.github.com/repos/spritebuilder/SpriteBuilder/issues/1275","id":68922447,"user":{"login":"LearnCocos2D","id":214599,"avatar_url":"https://avatars.githubusercontent.com/u/214599?v=3","gravatar_id":"","url":"https://api.github.com/users/LearnCocos2D","html_url":"https://github.com/LearnCocos2D","followers_url":"https://api.github.com/users/LearnCocos2D/followers","following_url":"https://api.github.com/users/LearnCocos2D/following{/other_user}","gists_url":"https://api.github.com/users/LearnCocos2D/gists{/gist_id}","starred_url":"https://api.github.com/users/LearnCocos2D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LearnCocos2D/subscriptions","organizations_url":"https://api.github.com/users/LearnCocos2D/orgs","repos_url":"https://api.github.com/users/LearnCocos2D/repos","events_url":"https://api.github.com/users/LearnCocos2D/events{/privacy}","received_events_url":"https://api.github.com/users/LearnCocos2D/received_events","type":"User","site_admin":false},"created_at":"2015-01-06T19:50:15Z","updated_at":"2015-01-06T19:50:15Z","body":"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. "}}