mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Fix String.contains. Fix crashing in rare cases or improper use of JSO
This commit is contained in:
parent
55e0905518
commit
4b77a5d15f
|
@ -413,8 +413,9 @@ public class TString extends TObject implements TSerializable, TComparable<TStri
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(TCharSequence s) {
|
public boolean contains(TCharSequence s) {
|
||||||
|
int sz = length() - s.length();
|
||||||
outer:
|
outer:
|
||||||
for (int i = 0; i < length(); ++i) {
|
for (int i = 0; i < sz; ++i) {
|
||||||
for (int j = 0; j < s.length(); ++j) {
|
for (int j = 0; j < s.length(); ++j) {
|
||||||
if (charAt(i + j) != s.charAt(j)) {
|
if (charAt(i + j) != s.charAt(j)) {
|
||||||
continue outer;
|
continue outer;
|
||||||
|
|
|
@ -58,7 +58,7 @@ class JSValueMarshaller {
|
||||||
if (type instanceof ValueType.Object) {
|
if (type instanceof ValueType.Object) {
|
||||||
String className = ((ValueType.Object) type).getClassName();
|
String className = ((ValueType.Object) type).getClassName();
|
||||||
ClassReader cls = classSource.get(className);
|
ClassReader cls = classSource.get(className);
|
||||||
if (cls.getAnnotations().get(JSFunctor.class.getName()) != null) {
|
if (cls != null && cls.getAnnotations().get(JSFunctor.class.getName()) != null) {
|
||||||
return wrapFunctor(location, var, cls);
|
return wrapFunctor(location, var, cls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,7 +221,7 @@ class JSValueMarshaller {
|
||||||
if (type instanceof ValueType.Object) {
|
if (type instanceof ValueType.Object) {
|
||||||
String className = ((ValueType.Object) type).getClassName();
|
String className = ((ValueType.Object) type).getClassName();
|
||||||
ClassReader cls = classSource.get(className);
|
ClassReader cls = classSource.get(className);
|
||||||
if (cls.getAnnotations().get(JSFunctor.class.getName()) != null) {
|
if (cls != null && cls.getAnnotations().get(JSFunctor.class.getName()) != null) {
|
||||||
return unwrapFunctor(location, var, cls);
|
return unwrapFunctor(location, var, cls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user