Skip to content

Commit 1184e99

Browse files
committed
Merge pull request #1351 from mgreter/fix/ci-issues
Fix issue with MSVC and temporary `string.c_str()`
2 parents efc1d5e + 94808f4 commit 1184e99

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

eval.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,8 @@ namespace Sass {
487487
// upgrade string to number if possible (issue #948)
488488
if (op_type == Sass_OP::DIV || op_type == Sass_OP::MUL) {
489489
if (String_Constant* str = dynamic_cast<String_Constant*>(rhs)) {
490-
const char* start = str->value().c_str();
490+
string value(str->value());
491+
const char* start = value.c_str();
491492
if (Prelexer::sequence < Prelexer::number >(start) != 0) {
492493
rhs = new (ctx.mem) Textual(rhs->pstate(), Textual::DIMENSION, str->value());
493494
rhs->is_delayed(false); rhs = rhs->perform(this);
@@ -511,23 +512,23 @@ namespace Sass {
511512
Expression::Concrete_Type r_type = rhs->concrete_type();
512513

513514
if (l_type == Expression::NUMBER && r_type == Expression::NUMBER) {
514-
Number* l_n = static_cast<Number*>(lhs);
515-
Number* r_n = static_cast<Number*>(rhs);
515+
Number* l_n = dynamic_cast<Number*>(lhs);
516+
Number* r_n = dynamic_cast<Number*>(rhs);
516517
return op_numbers(ctx, op_type, l_n, r_n);
517518
}
518519
if (l_type == Expression::NUMBER && r_type == Expression::COLOR) {
519-
Number* l_n = static_cast<Number*>(lhs);
520-
Color* r_c = static_cast<Color*>(rhs);
520+
Number* l_n = dynamic_cast<Number*>(lhs);
521+
Color* r_c = dynamic_cast<Color*>(rhs);
521522
return op_number_color(ctx, op_type, l_n, r_c);
522523
}
523524
if (l_type == Expression::COLOR && r_type == Expression::NUMBER) {
524-
Color* l_c = static_cast<Color*>(lhs);
525-
Number* r_n = static_cast<Number*>(rhs);
525+
Color* l_c = dynamic_cast<Color*>(lhs);
526+
Number* r_n = dynamic_cast<Number*>(rhs);
526527
return op_color_number(ctx, op_type, l_c, r_n);
527528
}
528529
if (l_type == Expression::COLOR && r_type == Expression::COLOR) {
529-
Color* l_c = static_cast<Color*>(lhs);
530-
Color* r_c = static_cast<Color*>(rhs);
530+
Color* l_c = dynamic_cast<Color*>(lhs);
531+
Color* r_c = dynamic_cast<Color*>(rhs);
531532
return op_colors(ctx, op_type, l_c, r_c);
532533
}
533534

0 commit comments

Comments
 (0)