facebook/three20 — Issue #753: TTStyledLayout.m logic error
Author: dav
Created: 2012-01-17 19:27:35+00:00
State: open

CLANG reports a logic error in this file. The best fix isn't immediately obvious to me so I'm just reporting it.

The problem is in the method below. If the image is nil then the code ends up with a grabage CGSize.

- (void)layoutImage:(TTStyledImageNode*)imageNode container:(TTStyledElement*)element {
UIImage* image = imageNode.image;
if (!image && imageNode.URL) {
if (!_invalidImages) {
_invalidImages = TTCreateNonRetainingArray();
}
[_invalidImages addObject:imageNode];
}

TTStyle* style = imageNode.className
? [[TTStyleSheet globalStyleSheet] styleWithSelector:imageNode.className] : nil;
TTBoxStyle* padding = style ? [style firstStyleOfClass:[TTBoxStyle class]] : nil;

CGFloat imageWidth = imageNode.width ? imageNode.width : image.size.width;
CGFloat imageHeight = imageNode.height ? imageNode.height : image.size.height;

![Analyzer Display](http://farm8.staticflickr.com/7142/6715875981_0aaf2c1a54_o.png)