Skip to content
Permalink
Browse files
Throw NPE on clear_task(null).
Fixes #1201
  • Loading branch information
LadyCailin committed May 31, 2020
1 parent cff540b commit eeb3b33a378aae16a3e0ca0b2a46572b2f7ec696
Showing 1 changed file with 7 additions and 1 deletion.
@@ -32,6 +32,7 @@
import com.laytonsmith.core.exceptions.CRE.CRECastException;
import com.laytonsmith.core.exceptions.CRE.CREFormatException;
import com.laytonsmith.core.exceptions.CRE.CREInsufficientArgumentsException;
import com.laytonsmith.core.exceptions.CRE.CRENullPointerException;
import com.laytonsmith.core.exceptions.CRE.CRERangeException;
import com.laytonsmith.core.exceptions.CRE.CREThrowable;
import com.laytonsmith.core.exceptions.CancelCommandException;
@@ -442,7 +443,8 @@ public String docs() {

@Override
public Class<? extends CREThrowable>[] thrown() {
return new Class[]{CRECastException.class, CREInsufficientArgumentsException.class};
return new Class[]{CRECastException.class, CREInsufficientArgumentsException.class,
CRENullPointerException.class};
}

@Override
@@ -460,6 +462,10 @@ public Mixed exec(Target t, Environment environment, Mixed... args) throws Confi
if(args.length == 0 && environment.getEnv(GlobalEnv.class).GetCustom("timeout-id") != null) {
StaticLayer.ClearFutureRunnable((Integer) environment.getEnv(GlobalEnv.class).GetCustom("timeout-id"));
} else if(args.length == 1) {
if(args[0] instanceof CNull) {
throw new CRENullPointerException("Null value sent to " + getName()
+ "(). Did you mean " + getName() + "(0)?", t);
}
StaticLayer.ClearFutureRunnable(Static.getInt32(args[0], t));
} else {
throw new CREInsufficientArgumentsException("No id was passed to clear_task, and it's not running inside a task either.", t);

0 comments on commit eeb3b33

Please sign in to comment.