Skip to content

Commit 21d37a9

Browse files
committed
Fix crash on nil image.
The only case I've actuall seen this is when a download is removed from the file system, outside of Signal. // FREEBIE
1 parent 82c903b commit 21d37a9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Signal/src/util/NumberUtil.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,18 @@ + (NSUInteger)smallestIntegerThatIsAtLeast:(NSUInteger)value andIsAMultipleOf:(N
4646

4747
+ (double)clamp:(double)value toMin:(double)min andMax:(double)max {
4848
ows_require(min <= max);
49-
if (value < min)
49+
if (isnan(value)) {
50+
return max;
51+
}
52+
53+
if (value < min) {
5054
return min;
51-
if (value > max)
55+
}
56+
57+
if (value > max) {
5258
return max;
59+
}
60+
5361
return value;
5462
}
5563

0 commit comments

Comments
 (0)