Program: 152722
Project: 152722
Buggy source:
@Override public Uri insert(Uri url,ContentValues initialValues){
  ContentValues values;
  long rowID;
  int type=Sms.MESSAGE_TYPE_ALL;
  int match=sURLMatcher.match(url);
  String table=TABLE_SMS;
switch (match) {
case SMS_ALL:
    Integer typeObj=initialValues.getAsInteger(Sms.TYPE);
  if (typeObj != null) {
    type=typeObj.intValue();
  }
 else {
    type=Sms.MESSAGE_TYPE_INBOX;
  }
break;
case SMS_INBOX:
type=Sms.MESSAGE_TYPE_INBOX;
break;
case SMS_FAILED:
type=Sms.MESSAGE_TYPE_FAILED;
break;
case SMS_QUEUED:
type=Sms.MESSAGE_TYPE_QUEUED;
break;
case SMS_SENT:
type=Sms.MESSAGE_TYPE_SENT;
break;
case SMS_DRAFT:
type=Sms.MESSAGE_TYPE_DRAFT;
break;
case SMS_OUTBOX:
type=Sms.MESSAGE_TYPE_OUTBOX;
break;
case SMS_RAW_MESSAGE:
table="String_Node_Str";
break;
case SMS_STATUS_PENDING:
table="String_Node_Str";
break;
case SMS_ATTACHMENT:
table="String_Node_Str";
break;
case SMS_NEW_THREAD_ID:
table="String_Node_Str";
break;
default :
Log.e(TAG,"String_Node_Str" + url);
return null;
}
SQLiteDatabase db=mOpenHelper.getWritableDatabase();
if (table.equals(TABLE_SMS)) {
boolean addDate=false;
boolean addType=false;
if (initialValues == null) {
values=new ContentValues(1);
addDate=true;
addType=true;
}
 else {
values=new ContentValues(initialValues);
if (!initialValues.containsKey(Sms.DATE)) {
addDate=true;
}
if (!initialValues.containsKey(Sms.TYPE)) {
addType=true;
}
}
if (addDate) {
values.put(Sms.DATE,new Long(System.currentTimeMillis()));
}
if (addType && (type != Sms.MESSAGE_TYPE_ALL)) {
values.put(Sms.TYPE,Integer.valueOf(type));
}
Long threadId=values.getAsLong(Sms.THREAD_ID);
String address=values.getAsString(Sms.ADDRESS);
if (((threadId == null) || (threadId == 0)) && (address != null)) {
values.put(Sms.THREAD_ID,Threads.getOrCreateThreadId(getContext(),address));
}
if (values.getAsInteger(Sms.TYPE) == Sms.MESSAGE_TYPE_DRAFT) {
db.delete(TABLE_SMS,"String_Node_Str",new String[]{values.getAsString(Sms.THREAD_ID),Integer.toString(Sms.MESSAGE_TYPE_DRAFT)});
}
if (type == Sms.MESSAGE_TYPE_INBOX) {
if ((values.getAsLong(Sms.PERSON) == null) && (!TextUtils.isEmpty(address))) {
Cursor cursor=getContext().getContentResolver().query(Uri.withAppendedPath(Contacts.Phones.CONTENT_FILTER_URL,address),new String[]{Contacts.Phones.PERSON_ID},null,null,null);
if (cursor != null) {
if (cursor.getCount() > 0) {
cursor.moveToFirst();
Long id=Long.valueOf(cursor.getLong(0));
values.put(Sms.PERSON,id);
}
cursor.deactivate();
}
}
}
 else {
values.put(Sms.READ,ONE);
}
}
 else {
if (initialValues == null) {
values=new ContentValues(1);
}
 else {
values=initialValues;
}
}
rowID=db.insert(table,"String_Node_Str",values);
if (rowID > 0) {
Uri uri=Uri.parse("String_Node_Str" + table + "String_Node_Str"+ rowID);
if (Log.isLoggable(TAG,Log.VERBOSE)) {
Log.d(TAG,"String_Node_Str" + uri + "String_Node_Str");
}
notifyChange(uri);
return uri;
}
 else {
Log.e(TAG,"String_Node_Str" + values.toString());
}
return null;
}

Fixed version (ground truth):
@Override public Uri insert(Uri url,ContentValues initialValues){
  ContentValues values;
  long rowID;
  int type=Sms.MESSAGE_TYPE_ALL;
  int match=sURLMatcher.match(url);
  String table=TABLE_SMS;
switch (match) {
case SMS_ALL:
    Integer typeObj=initialValues.getAsInteger(Sms.TYPE);
  if (typeObj != null) {
    type=typeObj.intValue();
  }
 else {
    type=Sms.MESSAGE_TYPE_INBOX;
  }
break;
case SMS_INBOX:
type=Sms.MESSAGE_TYPE_INBOX;
break;
case SMS_FAILED:
type=Sms.MESSAGE_TYPE_FAILED;
break;
case SMS_QUEUED:
type=Sms.MESSAGE_TYPE_QUEUED;
break;
case SMS_SENT:
type=Sms.MESSAGE_TYPE_SENT;
break;
case SMS_DRAFT:
type=Sms.MESSAGE_TYPE_DRAFT;
break;
case SMS_OUTBOX:
type=Sms.MESSAGE_TYPE_OUTBOX;
break;
case SMS_RAW_MESSAGE:
table="String_Node_Str";
break;
case SMS_STATUS_PENDING:
table="String_Node_Str";
break;
case SMS_ATTACHMENT:
table="String_Node_Str";
break;
case SMS_NEW_THREAD_ID:
table="String_Node_Str";
break;
default :
Log.e(TAG,"String_Node_Str" + url);
return null;
}
SQLiteDatabase db=mOpenHelper.getWritableDatabase();
if (table.equals(TABLE_SMS)) {
boolean addDate=false;
boolean addType=false;
if (initialValues == null) {
values=new ContentValues(1);
addDate=true;
addType=true;
}
 else {
values=new ContentValues(initialValues);
if (!initialValues.containsKey(Sms.DATE)) {
addDate=true;
}
if (!initialValues.containsKey(Sms.TYPE)) {
addType=true;
}
}
if (addDate) {
values.put(Sms.DATE,new Long(System.currentTimeMillis()));
}
if (addType && (type != Sms.MESSAGE_TYPE_ALL)) {
values.put(Sms.TYPE,Integer.valueOf(type));
}
Long threadId=values.getAsLong(Sms.THREAD_ID);
String address=values.getAsString(Sms.ADDRESS);
if (((threadId == null) || (threadId == 0)) && (address != null)) {
values.put(Sms.THREAD_ID,Threads.getOrCreateThreadId(getContext(),address));
}
if (values.getAsInteger(Sms.TYPE) == Sms.MESSAGE_TYPE_DRAFT) {
db.delete(TABLE_SMS,"String_Node_Str",new String[]{values.getAsString(Sms.THREAD_ID),Integer.toString(Sms.MESSAGE_TYPE_DRAFT)});
}
if (type == Sms.MESSAGE_TYPE_INBOX) {
if ((values.getAsLong(Sms.PERSON) == null) && (!TextUtils.isEmpty(address))) {
Cursor cursor=null;
Uri uri=Uri.withAppendedPath(Contacts.Phones.CONTENT_FILTER_URL,Uri.encode(address));
try {
cursor=getContext().getContentResolver().query(uri,CONTACT_QUERY_PROJECTION,null,null,null);
if (cursor.moveToFirst()) {
Long id=Long.valueOf(cursor.getLong(PERSON_ID_COLUMN));
values.put(Sms.PERSON,id);
}
}
 catch (Exception ex) {
Log.e(TAG,"String_Node_Str" + uri + "String_Node_Str",ex);
}
 finally {
if (cursor != null) {
cursor.close();
}
}
}
}
 else {
values.put(Sms.READ,ONE);
}
}
 else {
if (initialValues == null) {
values=new ContentValues(1);
}
 else {
values=initialValues;
}
}
rowID=db.insert(table,"String_Node_Str",values);
if (rowID > 0) {
Uri uri=Uri.parse("String_Node_Str" + table + "String_Node_Str"+ rowID);
if (Log.isLoggable(TAG,Log.VERBOSE)) {
Log.d(TAG,"String_Node_Str" + uri + "String_Node_Str");
}
notifyChange(uri);
return uri;
}
 else {
Log.e(TAG,"String_Node_Str" + values.toString());
}
return null;
}