From 2503ab6e92cb9893788d75a4062f1a8d7e6738d0 Mon Sep 17 00:00:00 2001 From: Ethan Nicholas Date: Thu, 5 Jan 2017 10:44:25 -0500 Subject: [PATCH] Fixed another division by zero error in skslc You'd think by now it would have occurred to me that mod is also a kind of division. BUG=skia:6087 Change-Id: I5128d09db94d06f10762ad5c23df32551c5e5855 Reviewed-on: https://skia-review.googlesource.com/6607 Reviewed-by: Greg Daniel Commit-Queue: Ethan Nicholas --- src/sksl/SkSLIRGenerator.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sksl/SkSLIRGenerator.cpp b/src/sksl/SkSLIRGenerator.cpp index 992db6e239..9f06c97d11 100644 --- a/src/sksl/SkSLIRGenerator.cpp +++ b/src/sksl/SkSLIRGenerator.cpp @@ -882,7 +882,12 @@ std::unique_ptr IRGenerator::constantFold(const Expression& left, } fErrors.error(right.fPosition, "division by zero"); return nullptr; - case Token::PERCENT: return RESULT(Int, %); + case Token::PERCENT: + if (rightVal) { + return RESULT(Int, %); + } + fErrors.error(right.fPosition, "division by zero"); + return nullptr; case Token::BITWISEAND: return RESULT(Int, &); case Token::BITWISEOR: return RESULT(Int, |); case Token::BITWISEXOR: return RESULT(Int, ^);