Fix String.contains. Fix crashing in rare cases or improper use of JSO

This commit is contained in:
Alexey Andreev 2018-09-19 12:47:32 +03:00
parent 55e0905518
commit 4b77a5d15f
2 changed files with 4 additions and 3 deletions

View File

@ -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;

View File

@ -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);
} }
} }