diff --git a/infer/models/java/src/android/database/Cursor.java b/infer/models/java/src/android/database/Cursor.java index ae5396fe1..4a0ac5272 100644 --- a/infer/models/java/src/android/database/Cursor.java +++ b/infer/models/java/src/android/database/Cursor.java @@ -6,9 +6,14 @@ package android.database; +import java.io.Closeable; + +import com.facebook.infer.models.InferUndefined; + import android.database.sqlite.SQLiteCursor; -public class Cursor { + +public class Cursor implements Closeable { public void close() { if (this instanceof SQLiteCursor) { @@ -16,4 +21,34 @@ public class Cursor { } } + public int getInt(int position) { + return InferUndefined.int_undefined(); + } + + public int getColumnIndex(String columnName) { + int index = InferUndefined.int_undefined(); + while (index < -1) {} + return index; + } + + public boolean move(int position) { + return InferUndefined.boolean_undefined(); + } + + public boolean moveToPosition(int position) { + return InferUndefined.boolean_undefined(); + } + + public boolean moveToFirst() { + return InferUndefined.boolean_undefined(); + } + + public boolean moveToNext() { + return InferUndefined.boolean_undefined(); + } + + public boolean moveToLast() { + return InferUndefined.boolean_undefined(); + } + } diff --git a/infer/models/java/src/android/database/sqlite/SQLiteCursor.java b/infer/models/java/src/android/database/sqlite/SQLiteCursor.java index f974b7447..e6bc95afb 100644 --- a/infer/models/java/src/android/database/sqlite/SQLiteCursor.java +++ b/infer/models/java/src/android/database/sqlite/SQLiteCursor.java @@ -23,8 +23,6 @@ import com.facebook.infer.models.InferUndefined; public class SQLiteCursor extends Cursor { - private String mEditTable; - @Deprecated public SQLiteCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { @@ -33,8 +31,7 @@ public class SQLiteCursor extends Cursor { public SQLiteCursor(SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { - mEditTable = new String(); - InferBuiltins.__set_file_attribute(mEditTable); + InferBuiltins.__set_file_attribute(this); } @@ -48,6 +45,7 @@ public class SQLiteCursor extends Cursor { } public void close() { - InferBuiltins.__set_mem_attribute(mEditTable); + InferBuiltins.__set_mem_attribute(this); } + } diff --git a/infer/tests/codetoanalyze/java/infer/CursorLeaks.java b/infer/tests/codetoanalyze/java/infer/CursorLeaks.java index 76d41a274..1f55762e1 100644 --- a/infer/tests/codetoanalyze/java/infer/CursorLeaks.java +++ b/infer/tests/codetoanalyze/java/infer/CursorLeaks.java @@ -213,4 +213,12 @@ public class CursorLeaks { Cursor c = new NamedCursor(cursor, "abc"); c.close(); } + + native NamedCursor createWrapper(Cursor cursor); + + public NamedCursor cursorAttachedTheWrapper(SQLiteDatabase sqLiteDatabase) { + Cursor cursor = sqLiteDatabase.query("events", null, null, null, null, null, null); + return createWrapper(cursor); + } + }