Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6660f55a authored by Jason Sams's avatar Jason Sams Committed by Android Git Automerger
Browse files

am 9a9916b5: am 2383f220: Merge "Validate objects are from the correct context."

* commit '9a9916b5':
  Validate objects are from the correct context.
parents 73e5582c 9a9916b5
Loading
Loading
Loading
Loading
+8 −0
Original line number Original line Diff line number Diff line
@@ -1004,6 +1004,14 @@ public class RenderScript {
        }
        }
    }
    }


    void validateObject(BaseObj o) {
        if (o != null) {
            if (o.mRS != this) {
                throw new RSIllegalArgumentException("Attempting to use an object across contexts.");
            }
        }
    }

    void validate() {
    void validate() {
        if (mContext == 0) {
        if (mContext == 0) {
            throw new RSInvalidStateException("Calling RS with no Context active.");
            throw new RSInvalidStateException("Calling RS with no Context active.");
+9 −0
Original line number Original line Diff line number Diff line
@@ -128,6 +128,9 @@ public class Script extends BaseObj {
     *
     *
     */
     */
    protected void forEach(int slot, Allocation ain, Allocation aout, FieldPacker v) {
    protected void forEach(int slot, Allocation ain, Allocation aout, FieldPacker v) {
        mRS.validate();
        mRS.validateObject(ain);
        mRS.validateObject(aout);
        if (ain == null && aout == null) {
        if (ain == null && aout == null) {
            throw new RSIllegalArgumentException(
            throw new RSIllegalArgumentException(
                "At least one of ain or aout is required to be non-null.");
                "At least one of ain or aout is required to be non-null.");
@@ -152,6 +155,9 @@ public class Script extends BaseObj {
     *
     *
     */
     */
    protected void forEach(int slot, Allocation ain, Allocation aout, FieldPacker v, LaunchOptions sc) {
    protected void forEach(int slot, Allocation ain, Allocation aout, FieldPacker v, LaunchOptions sc) {
        mRS.validate();
        mRS.validateObject(ain);
        mRS.validateObject(aout);
        if (ain == null && aout == null) {
        if (ain == null && aout == null) {
            throw new RSIllegalArgumentException(
            throw new RSIllegalArgumentException(
                "At least one of ain or aout is required to be non-null.");
                "At least one of ain or aout is required to be non-null.");
@@ -187,6 +193,7 @@ public class Script extends BaseObj {
     */
     */
    public void bindAllocation(Allocation va, int slot) {
    public void bindAllocation(Allocation va, int slot) {
        mRS.validate();
        mRS.validate();
        mRS.validateObject(va);
        if (va != null) {
        if (va != null) {
            if (mRS.getApplicationContext().getApplicationInfo().targetSdkVersion >= 20) {
            if (mRS.getApplicationContext().getApplicationInfo().targetSdkVersion >= 20) {
                final Type t = va.mType;
                final Type t = va.mType;
@@ -263,6 +270,8 @@ public class Script extends BaseObj {
     *
     *
     */
     */
    public void setVar(int index, BaseObj o) {
    public void setVar(int index, BaseObj o) {
        mRS.validate();
        mRS.validateObject(o);
        mRS.nScriptSetVarObj(getID(mRS), index, (o == null) ? 0 : o.getID(mRS));
        mRS.nScriptSetVarObj(getID(mRS), index, (o == null) ? 0 : o.getID(mRS));
    }
    }