Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Issue 296033004: Fix skpdiff segfault caused by NaN computation. (Closed)

Created:
6 years, 7 months ago by djsollen
Modified:
6 years, 7 months ago
CC:
skia-review_googlegroups.com
Visibility:
Public.

Description

Fix skpdiff segfault caused by NaN computation. BUG=skia:2574 Committed: https://code.google.com/p/skia/source/detail?r=14818

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+7 lines, -4 lines) Patch
M tools/skpdiff/SkPMetric.cpp View 2 chunks +7 lines, -4 lines 0 comments Download

Messages

Total messages: 11 (0 generated)
djsollen
6 years, 7 months ago (2014-05-20 19:38:53 UTC) #1
mtklein
lgtm
6 years, 7 months ago (2014-05-20 19:42:49 UTC) #2
rmistry
LGTM Thanks for working on this!
6 years, 7 months ago (2014-05-20 20:00:02 UTC) #3
djsollen
The CQ bit was checked by djsollen@google.com
6 years, 7 months ago (2014-05-20 20:00:47 UTC) #4
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://skia-tree-status.appspot.com/cq/djsollen@google.com/296033004/1
6 years, 7 months ago (2014-05-20 20:01:13 UTC) #5
commit-bot: I haz the power
Change committed as 14818
6 years, 7 months ago (2014-05-21 11:57:14 UTC) #6
djsollen
this patch fixes the broken window builders by using our macro.
6 years, 7 months ago (2014-05-21 12:11:02 UTC) #7
djsollen
The CQ bit was checked by djsollen@google.com
6 years, 7 months ago (2014-05-21 12:12:29 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://skia-tree-status.appspot.com/cq/djsollen@google.com/296033004/20001
6 years, 7 months ago (2014-05-21 12:13:01 UTC) #9
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 7 months ago (2014-05-21 12:13:03 UTC) #10
commit-bot: I haz the power
6 years, 7 months ago (2014-05-21 12:13:04 UTC) #11
Failed to apply patch for tools/skpdiff/SkPMetric.cpp:
While running patch -p1 --forward --force --no-backup-if-mismatch;
  patching file tools/skpdiff/SkPMetric.cpp
  Hunk #1 FAILED at 159.
  1 out of 1 hunk FAILED -- saving rejects to file
tools/skpdiff/SkPMetric.cpp.rej

Patch:       tools/skpdiff/SkPMetric.cpp
Index: tools/skpdiff/SkPMetric.cpp
diff --git a/tools/skpdiff/SkPMetric.cpp b/tools/skpdiff/SkPMetric.cpp
index
beba4974b770aefaeba6b7a2280de01b7c665517..4132ea5ab0c86876c6b6e198cc827e8f59016a72
100644
--- a/tools/skpdiff/SkPMetric.cpp
+++ b/tools/skpdiff/SkPMetric.cpp
@@ -159,10 +159,12 @@ static bool bitmap_to_cielab(const SkBitmap* bitmap,
ImageLAB* outImageLAB) {
 static float contrast_sensitivity(float cyclesPerDegree, float luminance) {
     float a = 440.0f * powf(1.0f + 0.7f / luminance, -0.2f);
     float b = 0.3f * powf(1.0f + 100.0f / luminance, 0.15f);
-    return a *
-           cyclesPerDegree *
-           expf(-b * cyclesPerDegree) *
-           sqrtf(1.0f + 0.06f * expf(b * cyclesPerDegree));
+    float exp = expf(-b * cyclesPerDegree);
+    float root = sqrtf(1.0f + 0.06f * expf(b * cyclesPerDegree));
+    if (!SkScalarIsFinite(exp)  || !SkScalarIsFinite(root)) {
+        return 0;
+    }
+    return a * cyclesPerDegree * exp * root;
 }
 
 #if 0

Powered by Google App Engine
This is Rietveld 408576698