Program: 184861
Project: 184861
Buggy source:
/** 
 * place a temporary callerinfo object in the hands of the caller and notify caller when the actual query is done.
 */
static CallerInfoToken startGetCallerInfo(Context context,Connection c,CallerInfoAsyncQuery.OnQueryCompleteListener listener,Object cookie){
  CallerInfoToken cit;
  if (c == null) {
    cit=new CallerInfoToken();
    cit.asyncQuery=null;
    return cit;
  }
  Object userDataObject=c.getUserData();
  if (userDataObject instanceof Uri) {
    cit=new CallerInfoToken();
    cit.currentInfo=new CallerInfo();
    cit.asyncQuery=CallerInfoAsyncQuery.startQuery(QUERY_TOKEN,context,(Uri)userDataObject,sCallerInfoQueryListener,c);
    cit.asyncQuery.addQueryListener(QUERY_TOKEN,listener,cookie);
    cit.isFinal=false;
    c.setUserData(cit);
    if (DBG)     log("String_Node_Str" + userDataObject);
  }
 else   if (userDataObject == null) {
    String number=c.getAddress();
    int cnapSpecialCase;
    cit=new CallerInfoToken();
    cit.currentInfo=new CallerInfo();
    if (DBG)     log("String_Node_Str" + number);
    if (!TextUtils.isEmpty(number)) {
      cit.currentInfo.cnapName=c.getCnapName();
      cit.currentInfo.name=cit.currentInfo.cnapName;
      cit.currentInfo.numberPresentation=c.getNumberPresentation();
      cit.currentInfo.namePresentation=c.getCnapNamePresentation();
      if (DBG)       log("String_Node_Str" + cit.currentInfo.cnapName + "String_Node_Str"+ cit.currentInfo.numberPresentation);
      if (cit.currentInfo.numberPresentation == Connection.PRESENTATION_ALLOWED) {
        cnapSpecialCase=checkCnapSpecialCases(number);
        if (cnapSpecialCase != CNAP_SPECIAL_CASE_NO) {
          if (cnapSpecialCase == Connection.PRESENTATION_RESTRICTED) {
            number=context.getString(R.string.private_num);
          }
 else           if (cnapSpecialCase == Connection.PRESENTATION_UNKNOWN) {
            number=context.getString(R.string.unknown);
          }
          cit.currentInfo.numberPresentation=cnapSpecialCase;
        }
      }
      cit.currentInfo.phoneNumber=number;
      cit.asyncQuery=CallerInfoAsyncQuery.startQuery(QUERY_TOKEN,context,number,sCallerInfoQueryListener,c);
      cit.asyncQuery.addQueryListener(QUERY_TOKEN,listener,cookie);
      cit.isFinal=false;
    }
 else {
      if (DBG)       log("String_Node_Str");
      cit.isFinal=true;
    }
    c.setUserData(cit);
    if (DBG)     log("String_Node_Str" + number);
  }
 else   if (userDataObject instanceof CallerInfoToken) {
    cit=(CallerInfoToken)userDataObject;
    if (cit.asyncQuery != null) {
      cit.asyncQuery.addQueryListener(QUERY_TOKEN,listener,cookie);
      if (DBG)       log("String_Node_Str" + listener.getClass().toString());
    }
 else {
      if (DBG)       log("String_Node_Str");
      if (cit.currentInfo == null) {
        cit.currentInfo=new CallerInfo();
      }
      cit.isFinal=true;
    }
  }
 else {
    cit=new CallerInfoToken();
    cit.currentInfo=(CallerInfo)userDataObject;
    cit.asyncQuery=null;
    cit.isFinal=true;
    if (DBG)     log("String_Node_Str");
  }
  return cit;
}

Fixed version (ground truth):
/** 
 * place a temporary callerinfo object in the hands of the caller and notify caller when the actual query is done.
 */
static CallerInfoToken startGetCallerInfo(Context context,Connection c,CallerInfoAsyncQuery.OnQueryCompleteListener listener,Object cookie){
  CallerInfoToken cit;
  if (c == null) {
    cit=new CallerInfoToken();
    cit.asyncQuery=null;
    return cit;
  }
  Object userDataObject=c.getUserData();
  if (userDataObject instanceof Uri) {
    cit=new CallerInfoToken();
    cit.currentInfo=new CallerInfo();
    cit.asyncQuery=CallerInfoAsyncQuery.startQuery(QUERY_TOKEN,context,(Uri)userDataObject,sCallerInfoQueryListener,c);
    cit.asyncQuery.addQueryListener(QUERY_TOKEN,listener,cookie);
    cit.isFinal=false;
    c.setUserData(cit);
    if (DBG)     log("String_Node_Str" + userDataObject);
  }
 else   if (userDataObject == null) {
    String number=c.getAddress();
    int cnapSpecialCase;
    cit=new CallerInfoToken();
    cit.currentInfo=new CallerInfo();
    if (DBG)     log("String_Node_Str" + number);
    if (!TextUtils.isEmpty(number)) {
      cit.currentInfo.cnapName=c.getCnapName();
      cit.currentInfo.name=cit.currentInfo.cnapName;
      cit.currentInfo.numberPresentation=c.getNumberPresentation();
      cit.currentInfo.namePresentation=c.getCnapNamePresentation();
      if (DBG)       log("String_Node_Str" + cit.currentInfo.cnapName + "String_Node_Str"+ cit.currentInfo.numberPresentation);
      if (cit.currentInfo.numberPresentation == Connection.PRESENTATION_ALLOWED) {
        cnapSpecialCase=checkCnapSpecialCases(number);
        if (cnapSpecialCase != CNAP_SPECIAL_CASE_NO) {
          if (cnapSpecialCase == Connection.PRESENTATION_RESTRICTED) {
            number=context.getString(R.string.private_num);
          }
 else           if (cnapSpecialCase == Connection.PRESENTATION_UNKNOWN) {
            number=context.getString(R.string.unknown);
          }
          cit.currentInfo.numberPresentation=cnapSpecialCase;
        }
      }
      cit.currentInfo.phoneNumber=number;
      cit.asyncQuery=CallerInfoAsyncQuery.startQuery(QUERY_TOKEN,context,number,sCallerInfoQueryListener,c);
      cit.asyncQuery.addQueryListener(QUERY_TOKEN,listener,cookie);
      cit.isFinal=false;
    }
 else {
      if (DBG)       log("String_Node_Str");
      cit.isFinal=true;
    }
    c.setUserData(cit);
    if (DBG)     log("String_Node_Str" + number);
  }
 else   if (userDataObject instanceof CallerInfoToken) {
    cit=(CallerInfoToken)userDataObject;
    if (cit.asyncQuery != null) {
      cit.asyncQuery.addQueryListener(QUERY_TOKEN,listener,cookie);
      if (DBG)       log("String_Node_Str" + listener.getClass().toString());
    }
 else {
      String updatedNumber=c.getAddress();
      if (DBG)       log("String_Node_Str" + updatedNumber);
      if (!TextUtils.isEmpty(updatedNumber)) {
        cit.currentInfo.phoneNumber=updatedNumber;
        cit.currentInfo.cnapName=c.getCnapName();
        cit.currentInfo.name=cit.currentInfo.cnapName;
        cit.currentInfo.numberPresentation=c.getNumberPresentation();
        cit.currentInfo.namePresentation=c.getCnapNamePresentation();
        if (DBG)         log("String_Node_Str" + cit.currentInfo.cnapName + "String_Node_Str"+ cit.currentInfo.numberPresentation);
        cit.asyncQuery=CallerInfoAsyncQuery.startQuery(QUERY_TOKEN,context,updatedNumber,sCallerInfoQueryListener,c);
        cit.asyncQuery.addQueryListener(QUERY_TOKEN,listener,cookie);
        cit.isFinal=false;
      }
 else {
        if (DBG)         log("String_Node_Str");
        if (cit.currentInfo == null) {
          cit.currentInfo=new CallerInfo();
        }
        cit.isFinal=true;
      }
    }
  }
 else {
    cit=new CallerInfoToken();
    cit.currentInfo=(CallerInfo)userDataObject;
    cit.asyncQuery=null;
    cit.isFinal=true;
    if (DBG)     log("String_Node_Str");
  }
  return cit;
}