Skip to content

Commit d9caa03

Browse files
author
volker
committed
Prevent NPE
1 parent 6e9f15c commit d9caa03

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/java/com/inet/sass/util/ColorUtil.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,9 @@ private static LexicalUnitImpl createHslFunction( double hue, double saturation,
677677
private static LexicalUnitImpl adjust(LexicalUnitImpl color, double amountByPercent, ColorOperation op) {
678678

679679
double[] hsl = colorToHsl(color);
680+
if( hsl == null ) {
681+
throw new ParseException( "The function adjust requires a color", color );
682+
}
680683
if (op == ColorOperation.Darken) {
681684
hsl[2] = hsl[2] - amountByPercent;
682685
hsl[2] = hsl[2] < 0 ? 0 : hsl[2];
@@ -685,8 +688,7 @@ private static LexicalUnitImpl adjust(LexicalUnitImpl color, double amountByPerc
685688
hsl[2] = hsl[2] > 100 ? 100 : hsl[2];
686689
}
687690
double alpha = getAlpha(color);
688-
return createHslaOrHslColor(hsl, alpha, color.getLineNumber(),
689-
color.getColumnNumber());
691+
return createHslaOrHslColor( hsl, alpha, color.getLineNumber(), color.getColumnNumber() );
690692
}
691693

692694
public static LexicalUnitImpl darken(LexicalUnitImpl color, double amount) {

0 commit comments

Comments
 (0)