nus-yam/ex-repair huggingface dataset:
Program: 976
Project: 976
Buggy source:
@Override public void handleMessage(Message msg){
switch (msg.what) {
case SHOW:
    handleShow((Bundle)msg.obj);
  return;
case HIDE:
handleHide();
return;
case RESET:
handleReset((Bundle)msg.obj);
return;
case VERIFY_UNLOCK:
handleVerifyUnlock();
return;
case NOTIFY_SCREEN_OFF:
handleNotifyScreenOff();
return;
case NOTIFY_SCREEN_ON:
handleNotifyScreenOn((IKeyguardShowCallback)msg.obj);
return;
case KEYGUARD_DONE:
handleKeyguardDone(msg.arg1 != 0,msg.arg2 != 0);
return;
case KEYGUARD_DONE_DRAWING:
handleKeyguardDoneDrawing();
return;
case KEYGUARD_DONE_AUTHENTICATING:
keyguardDone(true,true);
return;
case SET_HIDDEN:
handleSetHidden(msg.arg1 != 0);
break;
case KEYGUARD_TIMEOUT:
synchronized (KeyguardViewMediator.this) {
doKeyguardLocked((Bundle)msg.obj);
}
break;
case SHOW_ASSISTANT:
handleShowAssistant();
break;
case DISPATCH_EVENT:
handleDispatchEvent((MotionEvent)msg.obj);
break;
case LAUNCH_CAMERA:
handleLaunchCamera();
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
switch (msg.what) {
case SHOW:
    handleShow((Bundle)msg.obj);
  break;
case HIDE:
handleHide();
break;
case RESET:
handleReset((Bundle)msg.obj);
break;
case VERIFY_UNLOCK:
handleVerifyUnlock();
break;
case NOTIFY_SCREEN_OFF:
handleNotifyScreenOff();
break;
case NOTIFY_SCREEN_ON:
handleNotifyScreenOn((IKeyguardShowCallback)msg.obj);
break;
case KEYGUARD_DONE:
handleKeyguardDone(msg.arg1 != 0,msg.arg2 != 0);
break;
case KEYGUARD_DONE_DRAWING:
handleKeyguardDoneDrawing();
break;
case KEYGUARD_DONE_AUTHENTICATING:
keyguardDone(true,true);
break;
case SET_HIDDEN:
handleSetHidden(msg.arg1 != 0);
break;
case KEYGUARD_TIMEOUT:
synchronized (KeyguardViewMediator.this) {
doKeyguardLocked((Bundle)msg.obj);
}
break;
case SHOW_ASSISTANT:
handleShowAssistant();
break;
case DISPATCH_EVENT:
handleDispatchEvent((MotionEvent)msg.obj);
break;
case LAUNCH_CAMERA:
handleLaunchCamera();
break;
case DISMISS:
handleDismiss();
break;
}
}
Program: 977
Project: 977
Buggy source:
/** 
 * Dismiss the keyguard through the security layers.
 */
public void dismiss(){
  if (mShowing && !mHidden) {
    mKeyguardViewManager.dismiss();
  }
}

Fixed version (ground truth):
public void dismiss(){
  mHandler.sendEmptyMessage(DISMISS);
}
Program: 978
Project: 978
Buggy source:
public void keyguardDone(boolean authenticated,boolean wakeup){
  mKeyguardDonePending=false;
synchronized (this) {
    EventLog.writeEvent(70000,2);
    if (DEBUG)     Log.d(TAG,"String_Node_Str" + authenticated + "String_Node_Str");
    Message msg=mHandler.obtainMessage(KEYGUARD_DONE,authenticated ? 1 : 0,wakeup ? 1 : 0);
    mHandler.sendMessage(msg);
  }
}

Fixed version (ground truth):
public void keyguardDone(boolean authenticated,boolean wakeup){
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + authenticated + "String_Node_Str");
  EventLog.writeEvent(70000,2);
synchronized (this) {
    mKeyguardDonePending=false;
  }
  Message msg=mHandler.obtainMessage(KEYGUARD_DONE,authenticated ? 1 : 0,wakeup ? 1 : 0);
  mHandler.sendMessage(msg);
}
Program: 979
Project: 979
Buggy source:
@Override public void handleMessage(Message msg){
switch (msg.what) {
case SHOW:
    handleShow((Bundle)msg.obj);
  return;
case HIDE:
handleHide();
return;
case RESET:
handleReset((Bundle)msg.obj);
return;
case VERIFY_UNLOCK:
handleVerifyUnlock();
return;
case NOTIFY_SCREEN_OFF:
handleNotifyScreenOff();
return;
case NOTIFY_SCREEN_ON:
handleNotifyScreenOn((IKeyguardShowCallback)msg.obj);
return;
case KEYGUARD_DONE:
handleKeyguardDone(msg.arg1 != 0,msg.arg2 != 0);
return;
case KEYGUARD_DONE_DRAWING:
handleKeyguardDoneDrawing();
return;
case KEYGUARD_DONE_AUTHENTICATING:
keyguardDone(true,true);
return;
case SET_HIDDEN:
handleSetHidden(msg.arg1 != 0);
break;
case KEYGUARD_TIMEOUT:
synchronized (KeyguardViewMediator.this) {
doKeyguardLocked((Bundle)msg.obj);
}
break;
case SHOW_ASSISTANT:
handleShowAssistant();
break;
case DISPATCH_EVENT:
handleDispatchEvent((MotionEvent)msg.obj);
break;
case LAUNCH_CAMERA:
handleLaunchCamera();
break;
}
}

Fixed version (ground truth):
@Override public void handleMessage(Message msg){
switch (msg.what) {
case SHOW:
    handleShow((Bundle)msg.obj);
  break;
case HIDE:
handleHide();
break;
case RESET:
handleReset((Bundle)msg.obj);
break;
case VERIFY_UNLOCK:
handleVerifyUnlock();
break;
case NOTIFY_SCREEN_OFF:
handleNotifyScreenOff();
break;
case NOTIFY_SCREEN_ON:
handleNotifyScreenOn((IKeyguardShowCallback)msg.obj);
break;
case KEYGUARD_DONE:
handleKeyguardDone(msg.arg1 != 0,msg.arg2 != 0);
break;
case KEYGUARD_DONE_DRAWING:
handleKeyguardDoneDrawing();
break;
case KEYGUARD_DONE_AUTHENTICATING:
keyguardDone(true,true);
break;
case SET_HIDDEN:
handleSetHidden(msg.arg1 != 0);
break;
case KEYGUARD_TIMEOUT:
synchronized (KeyguardViewMediator.this) {
doKeyguardLocked((Bundle)msg.obj);
}
break;
case SHOW_ASSISTANT:
handleShowAssistant();
break;
case DISPATCH_EVENT:
handleDispatchEvent((MotionEvent)msg.obj);
break;
case LAUNCH_CAMERA:
handleLaunchCamera();
break;
case DISMISS:
handleDismiss();
break;
}
}
Program: 981
Project: 981
Buggy source:
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  final boolean wasFormatted=mFormatItems;
  mFormatItems=MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY;
  if (wasFormatted != mFormatItems) {
    mFormatItemsWidth=0;
  }
  final int widthSize=MeasureSpec.getMode(widthMeasureSpec);
  if (mFormatItems && mMenu != null && widthSize != mFormatItemsWidth) {
    mFormatItemsWidth=widthSize;
    mMenu.onItemsChanged(true);
  }
  if (mFormatItems) {
    onMeasureExactFormat(widthMeasureSpec,heightMeasureSpec);
  }
 else {
    final int childCount=getChildCount();
    for (int i=0; i < childCount; i++) {
      final View child=getChildAt(i);
      final LayoutParams lp=(LayoutParams)child.getLayoutParams();
      lp.leftMargin=lp.rightMargin=0;
    }
    super.onMeasure(widthMeasureSpec,heightMeasureSpec);
  }
}

Fixed version (ground truth):
@Override protected void onMeasure(int widthMeasureSpec,int heightMeasureSpec){
  final boolean wasFormatted=mFormatItems;
  mFormatItems=MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY;
  if (wasFormatted != mFormatItems) {
    mFormatItemsWidth=0;
  }
  final int widthSize=MeasureSpec.getSize(widthMeasureSpec);
  if (mFormatItems && mMenu != null && widthSize != mFormatItemsWidth) {
    mFormatItemsWidth=widthSize;
    mMenu.onItemsChanged(true);
  }
  if (mFormatItems) {
    onMeasureExactFormat(widthMeasureSpec,heightMeasureSpec);
  }
 else {
    final int childCount=getChildCount();
    for (int i=0; i < childCount; i++) {
      final View child=getChildAt(i);
      final LayoutParams lp=(LayoutParams)child.getLayoutParams();
      lp.leftMargin=lp.rightMargin=0;
    }
    super.onMeasure(widthMeasureSpec,heightMeasureSpec);
  }
}
Program: 985
Project: 985
Buggy source:
@Override public boolean bindService(Intent service,ServiceConnection conn,int flags){
  warnIfCallingFromSystemProcess();
  return bindServiceAsUser(service,conn,flags,Process.myUserHandle());
}

Fixed version (ground truth):
@Override public boolean bindService(Intent service,ServiceConnection conn,int flags){
  warnIfCallingFromSystemProcess();
  return bindServiceCommon(service,conn,flags,Process.myUserHandle());
}
Program: 986
Project: 986
Buggy source:
@Override public ComponentName startServiceAsUser(Intent service,UserHandle user){
  try {
    if (service.getComponent() == null && service.getPackage() == null) {
      if (getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.KITKAT) {
        IllegalArgumentException ex=new IllegalArgumentException("String_Node_Str" + service);
        Log.e(TAG,"String_Node_Str",ex);
      }
    }
    service.prepareToLeaveProcess();
    ComponentName cn=ActivityManagerNative.getDefault().startService(mMainThread.getApplicationThread(),service,service.resolveTypeIfNeeded(getContentResolver()),user.getIdentifier());
    if (cn != null) {
      if (cn.getPackageName().equals("String_Node_Str")) {
        throw new SecurityException("String_Node_Str" + service + "String_Node_Str"+ cn.getClassName());
      }
 else       if (cn.getPackageName().equals("String_Node_Str")) {
        throw new SecurityException("String_Node_Str" + service + "String_Node_Str"+ cn.getClassName());
      }
    }
    return cn;
  }
 catch (  RemoteException e) {
    return null;
  }
}

Fixed version (ground truth):
@Override public ComponentName startServiceAsUser(Intent service,UserHandle user){
  return startServiceCommon(service,user);
}
Program: 987
Project: 987
Buggy source:
@Override public boolean stopServiceAsUser(Intent service,UserHandle user){
  try {
    if (service.getComponent() == null && service.getPackage() == null) {
      if (getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.KITKAT) {
        IllegalArgumentException ex=new IllegalArgumentException("String_Node_Str" + service);
        Log.e(TAG,"String_Node_Str",ex);
      }
    }
    service.prepareToLeaveProcess();
    int res=ActivityManagerNative.getDefault().stopService(mMainThread.getApplicationThread(),service,service.resolveTypeIfNeeded(getContentResolver()),user.getIdentifier());
    if (res < 0) {
      throw new SecurityException("String_Node_Str" + service);
    }
    return res != 0;
  }
 catch (  RemoteException e) {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean stopServiceAsUser(Intent service,UserHandle user){
  return stopServiceCommon(service,user);
}
Program: 988
Project: 988
Buggy source:
/** 
 * @hide 
 */
@Override public boolean bindServiceAsUser(Intent service,ServiceConnection conn,int flags,UserHandle user){
  IServiceConnection sd;
  if (conn == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (mPackageInfo != null) {
    sd=mPackageInfo.getServiceDispatcher(conn,getOuterContext(),mMainThread.getHandler(),flags);
  }
 else {
    throw new RuntimeException("String_Node_Str");
  }
  if (service.getComponent() == null && service.getPackage() == null) {
    if (getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.KITKAT) {
      IllegalArgumentException ex=new IllegalArgumentException("String_Node_Str" + service);
      Log.e(TAG,"String_Node_Str",ex);
    }
  }
  try {
    IBinder token=getActivityToken();
    if (token == null && (flags & BIND_AUTO_CREATE) == 0 && mPackageInfo != null && mPackageInfo.getApplicationInfo().targetSdkVersion < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      flags|=BIND_WAIVE_PRIORITY;
    }
    service.prepareToLeaveProcess();
    int res=ActivityManagerNative.getDefault().bindService(mMainThread.getApplicationThread(),getActivityToken(),service,service.resolveTypeIfNeeded(getContentResolver()),sd,flags,user.getIdentifier());
    if (res < 0) {
      throw new SecurityException("String_Node_Str" + service);
    }
    return res != 0;
  }
 catch (  RemoteException e) {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * @hide 
 */
@Override public boolean bindServiceAsUser(Intent service,ServiceConnection conn,int flags,UserHandle user){
  return bindServiceCommon(service,conn,flags,user);
}
Program: 989
Project: 989
Buggy source:
@Override public ComponentName startService(Intent service){
  warnIfCallingFromSystemProcess();
  return startServiceAsUser(service,mUser);
}

Fixed version (ground truth):
@Override public ComponentName startService(Intent service){
  warnIfCallingFromSystemProcess();
  return startServiceCommon(service,mUser);
}
Program: 990
Project: 990
Buggy source:
@Override public boolean stopService(Intent service){
  warnIfCallingFromSystemProcess();
  return stopServiceAsUser(service,mUser);
}

Fixed version (ground truth):
@Override public boolean stopService(Intent service){
  warnIfCallingFromSystemProcess();
  return stopServiceCommon(service,mUser);
}
Program: 991
Project: 991
Buggy source:
/** 
 * TODO: optimize this later (getting just the value part of a Bundle with a single pair) once Bundle.forPair() above is implemented with a special single-value Map implementation/serialization. Note: value in single-pair Bundle may be null.
 * @hide
 */
public String getPairValue(){
  unparcel();
  int size=mMap.size();
  if (size > 1) {
    Log.w(LOG_TAG,"String_Node_Str");
  }
  if (size == 0) {
    return null;
  }
  Object o=mMap.valueAt(0);
  try {
    return (String)o;
  }
 catch (  ClassCastException e) {
    typeWarning("String_Node_Str",o,"String_Node_Str",e);
    return null;
  }
}

Fixed version (ground truth):
/** 
 * TODO: optimize this later (getting just the value part of a Bundle with a single pair) once Bundle.forPair() above is implemented with a special single-value Map implementation/serialization. Note: value in single-pair Bundle may be null.
 * @hide
 */
public String getPairValue(){
  unparcel();
  int size=mMap.size();
  if (size > 1) {
    Log.w(TAG,"String_Node_Str");
  }
  if (size == 0) {
    return null;
  }
  Object o=mMap.valueAt(0);
  try {
    return (String)o;
  }
 catch (  ClassCastException e) {
    typeWarning("String_Node_Str",o,"String_Node_Str",e);
    return null;
  }
}
Program: 992
Project: 992
Buggy source:
/** 
 * Writes the Bundle contents to a Parcel, typically in order for it to be passed through an IBinder connection.
 * @param parcel The parcel to copy this bundle to.
 */
public void writeToParcel(Parcel parcel,int flags){
  final boolean oldAllowFds=parcel.pushAllowFds(mAllowFds);
  try {
    if (mParcelledData != null) {
      int length=mParcelledData.dataSize();
      parcel.writeInt(length);
      parcel.writeInt(BUNDLE_MAGIC);
      parcel.appendFrom(mParcelledData,0,length);
    }
 else {
      parcel.writeInt(-1);
      parcel.writeInt(BUNDLE_MAGIC);
      int oldPos=parcel.dataPosition();
      parcel.writeArrayMapInternal(mMap);
      int newPos=parcel.dataPosition();
      parcel.setDataPosition(oldPos - 8);
      int length=newPos - oldPos;
      parcel.writeInt(length);
      parcel.setDataPosition(newPos);
    }
  }
  finally {
    parcel.restoreAllowFds(oldAllowFds);
  }
}

Fixed version (ground truth):
/** 
 * Writes the Bundle contents to a Parcel, typically in order for it to be passed through an IBinder connection.
 * @param parcel The parcel to copy this bundle to.
 */
public void writeToParcel(Parcel parcel,int flags){
  final boolean oldAllowFds=parcel.pushAllowFds(mAllowFds);
  try {
    if (mParcelledData != null) {
      int length=mParcelledData.dataSize();
      parcel.writeInt(length);
      parcel.writeInt(BUNDLE_MAGIC);
      parcel.appendFrom(mParcelledData,0,length);
    }
 else {
      int lengthPos=parcel.dataPosition();
      parcel.writeInt(-1);
      parcel.writeInt(BUNDLE_MAGIC);
      int startPos=parcel.dataPosition();
      parcel.writeArrayMapInternal(mMap);
      int endPos=parcel.dataPosition();
      parcel.setDataPosition(lengthPos);
      int length=endPos - startPos;
      parcel.writeInt(length);
      parcel.setDataPosition(endPos);
    }
  }
  finally {
    parcel.restoreAllowFds(oldAllowFds);
  }
}
Program: 993
Project: 993
Buggy source:
/** 
 * If the underlying data are stored as a Parcel, unparcel them using the currently assigned class loader.
 */
synchronized void unparcel(){
  if (mParcelledData == null) {
    return;
  }
  int N=mParcelledData.readInt();
  if (N < 0) {
    return;
  }
  if (mMap == null) {
    mMap=new ArrayMap<String,Object>(N);
  }
 else {
    mMap.erase();
    mMap.ensureCapacity(N);
  }
  mParcelledData.readArrayMapInternal(mMap,N,mClassLoader);
  mParcelledData.recycle();
  mParcelledData=null;
}

Fixed version (ground truth):
/** 
 * If the underlying data are stored as a Parcel, unparcel them using the currently assigned class loader.
 */
synchronized void unparcel(){
  if (mParcelledData == null) {
    if (DEBUG)     Log.d(TAG,"String_Node_Str" + Integer.toHexString(System.identityHashCode(this)) + "String_Node_Str");
    return;
  }
  int N=mParcelledData.readInt();
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + Integer.toHexString(System.identityHashCode(this)) + "String_Node_Str"+ N+ "String_Node_Str");
  if (N < 0) {
    return;
  }
  if (mMap == null) {
    mMap=new ArrayMap<String,Object>(N);
  }
 else {
    mMap.erase();
    mMap.ensureCapacity(N);
  }
  mParcelledData.readArrayMapInternal(mMap,N,mClassLoader);
  mParcelledData.recycle();
  mParcelledData=null;
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + Integer.toHexString(System.identityHashCode(this)) + "String_Node_Str"+ mMap);
}
Program: 994
Project: 994
Buggy source:
void readFromParcelInner(Parcel parcel,int length){
  int magic=parcel.readInt();
  if (magic != BUNDLE_MAGIC) {
    throw new IllegalStateException("String_Node_Str" + Integer.toHexString(magic));
  }
  int offset=parcel.dataPosition();
  parcel.setDataPosition(offset + length);
  Parcel p=Parcel.obtain();
  p.setDataPosition(0);
  p.appendFrom(parcel,offset,length);
  p.setDataPosition(0);
  if (mMap != null) {
    if (mFdsKnown) {
      mHasFds|=p.hasFileDescriptors();
    }
    int N=p.readInt();
    p.readArrayMapSafelyInternal(mMap,N,mClassLoader);
    p.recycle();
  }
 else {
    mParcelledData=p;
    mHasFds=p.hasFileDescriptors();
    mFdsKnown=true;
  }
}

Fixed version (ground truth):
void readFromParcelInner(Parcel parcel,int length){
  int magic=parcel.readInt();
  if (magic != BUNDLE_MAGIC) {
    throw new IllegalStateException("String_Node_Str" + Integer.toHexString(magic));
  }
  int offset=parcel.dataPosition();
  parcel.setDataPosition(offset + length);
  Parcel p=Parcel.obtain();
  p.setDataPosition(0);
  p.appendFrom(parcel,offset,length);
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + Integer.toHexString(System.identityHashCode(this)) + "String_Node_Str"+ length+ "String_Node_Str"+ offset);
  p.setDataPosition(0);
  mParcelledData=p;
  mHasFds=p.hasFileDescriptors();
  mFdsKnown=true;
}
Program: 995
Project: 995
Buggy source:
/** 
 * Read and return a new Bundle object from the parcel at the current dataPosition(), using the given class loader to initialize the class loader of the Bundle for later retrieval of Parcelable objects. Returns null if the previously written Bundle object was null.
 */
public final Bundle readBundle(ClassLoader loader){
  int length=readInt();
  if (length < 0) {
    return null;
  }
  final Bundle bundle=new Bundle(this,length);
  if (loader != null) {
    bundle.setClassLoader(loader);
  }
  return bundle;
}

Fixed version (ground truth):
/** 
 * Read and return a new Bundle object from the parcel at the current dataPosition(), using the given class loader to initialize the class loader of the Bundle for later retrieval of Parcelable objects. Returns null if the previously written Bundle object was null.
 */
public final Bundle readBundle(ClassLoader loader){
  int length=readInt();
  if (length < 0) {
    if (Bundle.DEBUG)     Log.d(TAG,"String_Node_Str" + length);
    return null;
  }
  final Bundle bundle=new Bundle(this,length);
  if (loader != null) {
    bundle.setClassLoader(loader);
  }
  return bundle;
}
Program: 996
Project: 996
Buggy source:
/** 
 * @hide Like  {@link #clear}, but doesn't reduce the capacity of the ArrayMap.
 */
public void erase(){
  if (mSize > 0) {
    final int N=mSize << 1;
    final Object[] array=mArray;
    for (int i=0; i < N; i++) {
      array[i]=null;
    }
  }
}

Fixed version (ground truth):
/** 
 * @hide Like  {@link #clear}, but doesn't reduce the capacity of the ArrayMap.
 */
public void erase(){
  if (mSize > 0) {
    final int N=mSize << 1;
    final Object[] array=mArray;
    for (int i=0; i < N; i++) {
      array[i]=null;
    }
    mSize=0;
  }
}
Program: 997
Project: 997
Buggy source:
/** 
 * TODO: optimize this later (getting just the value part of a Bundle with a single pair) once Bundle.forPair() above is implemented with a special single-value Map implementation/serialization. Note: value in single-pair Bundle may be null.
 * @hide
 */
public String getPairValue(){
  unparcel();
  int size=mMap.size();
  if (size > 1) {
    Log.w(LOG_TAG,"String_Node_Str");
  }
  if (size == 0) {
    return null;
  }
  Object o=mMap.valueAt(0);
  try {
    return (String)o;
  }
 catch (  ClassCastException e) {
    typeWarning("String_Node_Str",o,"String_Node_Str",e);
    return null;
  }
}

Fixed version (ground truth):
/** 
 * TODO: optimize this later (getting just the value part of a Bundle with a single pair) once Bundle.forPair() above is implemented with a special single-value Map implementation/serialization. Note: value in single-pair Bundle may be null.
 * @hide
 */
public String getPairValue(){
  unparcel();
  int size=mMap.size();
  if (size > 1) {
    Log.w(TAG,"String_Node_Str");
  }
  if (size == 0) {
    return null;
  }
  Object o=mMap.valueAt(0);
  try {
    return (String)o;
  }
 catch (  ClassCastException e) {
    typeWarning("String_Node_Str",o,"String_Node_Str",e);
    return null;
  }
}
Program: 998
Project: 998
Buggy source:
/** 
 * Writes the Bundle contents to a Parcel, typically in order for it to be passed through an IBinder connection.
 * @param parcel The parcel to copy this bundle to.
 */
public void writeToParcel(Parcel parcel,int flags){
  final boolean oldAllowFds=parcel.pushAllowFds(mAllowFds);
  try {
    if (mParcelledData != null) {
      int length=mParcelledData.dataSize();
      parcel.writeInt(length);
      parcel.writeInt(BUNDLE_MAGIC);
      parcel.appendFrom(mParcelledData,0,length);
    }
 else {
      parcel.writeInt(-1);
      parcel.writeInt(BUNDLE_MAGIC);
      int oldPos=parcel.dataPosition();
      parcel.writeArrayMapInternal(mMap);
      int newPos=parcel.dataPosition();
      parcel.setDataPosition(oldPos - 8);
      int length=newPos - oldPos;
      parcel.writeInt(length);
      parcel.setDataPosition(newPos);
    }
  }
  finally {
    parcel.restoreAllowFds(oldAllowFds);
  }
}

Fixed version (ground truth):
/** 
 * Writes the Bundle contents to a Parcel, typically in order for it to be passed through an IBinder connection.
 * @param parcel The parcel to copy this bundle to.
 */
public void writeToParcel(Parcel parcel,int flags){
  final boolean oldAllowFds=parcel.pushAllowFds(mAllowFds);
  try {
    if (mParcelledData != null) {
      int length=mParcelledData.dataSize();
      parcel.writeInt(length);
      parcel.writeInt(BUNDLE_MAGIC);
      parcel.appendFrom(mParcelledData,0,length);
    }
 else {
      int lengthPos=parcel.dataPosition();
      parcel.writeInt(-1);
      parcel.writeInt(BUNDLE_MAGIC);
      int startPos=parcel.dataPosition();
      parcel.writeArrayMapInternal(mMap);
      int endPos=parcel.dataPosition();
      parcel.setDataPosition(lengthPos);
      int length=endPos - startPos;
      parcel.writeInt(length);
      parcel.setDataPosition(endPos);
    }
  }
  finally {
    parcel.restoreAllowFds(oldAllowFds);
  }
}
Program: 999
Project: 999
Buggy source:
/** 
 * If the underlying data are stored as a Parcel, unparcel them using the currently assigned class loader.
 */
synchronized void unparcel(){
  if (mParcelledData == null) {
    return;
  }
  int N=mParcelledData.readInt();
  if (N < 0) {
    return;
  }
  if (mMap == null) {
    mMap=new ArrayMap<String,Object>(N);
  }
 else {
    mMap.erase();
    mMap.ensureCapacity(N);
  }
  mParcelledData.readArrayMapInternal(mMap,N,mClassLoader);
  mParcelledData.recycle();
  mParcelledData=null;
}

Fixed version (ground truth):
/** 
 * If the underlying data are stored as a Parcel, unparcel them using the currently assigned class loader.
 */
synchronized void unparcel(){
  if (mParcelledData == null) {
    if (DEBUG)     Log.d(TAG,"String_Node_Str" + Integer.toHexString(System.identityHashCode(this)) + "String_Node_Str");
    return;
  }
  int N=mParcelledData.readInt();
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + Integer.toHexString(System.identityHashCode(this)) + "String_Node_Str"+ N+ "String_Node_Str");
  if (N < 0) {
    return;
  }
  if (mMap == null) {
    mMap=new ArrayMap<String,Object>(N);
  }
 else {
    mMap.erase();
    mMap.ensureCapacity(N);
  }
  mParcelledData.readArrayMapInternal(mMap,N,mClassLoader);
  mParcelledData.recycle();
  mParcelledData=null;
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + Integer.toHexString(System.identityHashCode(this)) + "String_Node_Str"+ mMap);
}
Program: 1000
Project: 1000
Buggy source:
void readFromParcelInner(Parcel parcel,int length){
  int magic=parcel.readInt();
  if (magic != BUNDLE_MAGIC) {
    throw new IllegalStateException("String_Node_Str" + Integer.toHexString(magic));
  }
  int offset=parcel.dataPosition();
  parcel.setDataPosition(offset + length);
  Parcel p=Parcel.obtain();
  p.setDataPosition(0);
  p.appendFrom(parcel,offset,length);
  p.setDataPosition(0);
  if (mMap != null) {
    if (mFdsKnown) {
      mHasFds|=p.hasFileDescriptors();
    }
    int N=p.readInt();
    p.readArrayMapSafelyInternal(mMap,N,mClassLoader);
    p.recycle();
  }
 else {
    mParcelledData=p;
    mHasFds=p.hasFileDescriptors();
    mFdsKnown=true;
  }
}

Fixed version (ground truth):
void readFromParcelInner(Parcel parcel,int length){
  int magic=parcel.readInt();
  if (magic != BUNDLE_MAGIC) {
    throw new IllegalStateException("String_Node_Str" + Integer.toHexString(magic));
  }
  int offset=parcel.dataPosition();
  parcel.setDataPosition(offset + length);
  Parcel p=Parcel.obtain();
  p.setDataPosition(0);
  p.appendFrom(parcel,offset,length);
  if (DEBUG)   Log.d(TAG,"String_Node_Str" + Integer.toHexString(System.identityHashCode(this)) + "String_Node_Str"+ length+ "String_Node_Str"+ offset);
  p.setDataPosition(0);
  mParcelledData=p;
  mHasFds=p.hasFileDescriptors();
  mFdsKnown=true;
}
Program: 1001
Project: 1001
Buggy source:
/** 
 * Read and return a new Bundle object from the parcel at the current dataPosition(), using the given class loader to initialize the class loader of the Bundle for later retrieval of Parcelable objects. Returns null if the previously written Bundle object was null.
 */
public final Bundle readBundle(ClassLoader loader){
  int length=readInt();
  if (length < 0) {
    return null;
  }
  final Bundle bundle=new Bundle(this,length);
  if (loader != null) {
    bundle.setClassLoader(loader);
  }
  return bundle;
}

Fixed version (ground truth):
/** 
 * Read and return a new Bundle object from the parcel at the current dataPosition(), using the given class loader to initialize the class loader of the Bundle for later retrieval of Parcelable objects. Returns null if the previously written Bundle object was null.
 */
public final Bundle readBundle(ClassLoader loader){
  int length=readInt();
  if (length < 0) {
    if (Bundle.DEBUG)     Log.d(TAG,"String_Node_Str" + length);
    return null;
  }
  final Bundle bundle=new Bundle(this,length);
  if (loader != null) {
    bundle.setClassLoader(loader);
  }
  return bundle;
}
Program: 1002
Project: 1002
Buggy source:
/** 
 * @hide Like  {@link #clear}, but doesn't reduce the capacity of the ArrayMap.
 */
public void erase(){
  if (mSize > 0) {
    final int N=mSize << 1;
    final Object[] array=mArray;
    for (int i=0; i < N; i++) {
      array[i]=null;
    }
  }
}

Fixed version (ground truth):
/** 
 * @hide Like  {@link #clear}, but doesn't reduce the capacity of the ArrayMap.
 */
public void erase(){
  if (mSize > 0) {
    final int N=mSize << 1;
    final Object[] array=mArray;
    for (int i=0; i < N; i++) {
      array[i]=null;
    }
    mSize=0;
  }
}
Program: 1003
Project: 1003
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  String action=intent.getAction();
  if (action.equals(Intent.ACTION_SCREEN_ON)) {
    mWifiController.sendMessage(CMD_SCREEN_ON);
  }
 else   if (action.equals(Intent.ACTION_SCREEN_OFF)) {
    mWifiController.sendMessage(CMD_SCREEN_OFF);
  }
 else   if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
    int pluggedType=intent.getIntExtra("String_Node_Str",0);
    mWifiController.sendMessage(CMD_BATTERY_CHANGED,pluggedType,0,null);
  }
 else   if (action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
    int state=intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE,BluetoothAdapter.STATE_DISCONNECTED);
    mWifiStateMachine.sendBluetoothAdapterStateChange(state);
  }
 else   if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) {
    boolean emergencyMode=intent.getBooleanExtra("String_Node_Str",false);
    mWifiController.sendMessage(CMD_EMERGENCY_MODE_CHANGED,emergencyMode ? 1 : 0,0);
  }
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  String action=intent.getAction();
  if (action.equals(Intent.ACTION_SCREEN_ON)) {
    mWifiController.sendMessage(CMD_SCREEN_ON);
  }
 else   if (action.equals(Intent.ACTION_USER_PRESENT)) {
    mWifiController.sendMessage(CMD_USER_PRESENT);
  }
 else   if (action.equals(Intent.ACTION_SCREEN_OFF)) {
    mWifiController.sendMessage(CMD_SCREEN_OFF);
  }
 else   if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
    int pluggedType=intent.getIntExtra("String_Node_Str",0);
    mWifiController.sendMessage(CMD_BATTERY_CHANGED,pluggedType,0,null);
  }
 else   if (action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
    int state=intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE,BluetoothAdapter.STATE_DISCONNECTED);
    mWifiStateMachine.sendBluetoothAdapterStateChange(state);
  }
 else   if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) {
    boolean emergencyMode=intent.getBooleanExtra("String_Node_Str",false);
    mWifiController.sendMessage(CMD_EMERGENCY_MODE_CHANGED,emergencyMode ? 1 : 0,0);
  }
}
Program: 1004
Project: 1004
Buggy source:
private void registerForBroadcasts(){
  IntentFilter intentFilter=new IntentFilter();
  intentFilter.addAction(Intent.ACTION_SCREEN_ON);
  intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
  intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
  intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
  intentFilter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
  intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
  mContext.registerReceiver(mReceiver,intentFilter);
}

Fixed version (ground truth):
private void registerForBroadcasts(){
  IntentFilter intentFilter=new IntentFilter();
  intentFilter.addAction(Intent.ACTION_SCREEN_ON);
  intentFilter.addAction(Intent.ACTION_USER_PRESENT);
  intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
  intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
  intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
  intentFilter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
  intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
  mContext.registerReceiver(mReceiver,intentFilter);
}
Program: 1006
Project: 1006
Buggy source:
boolean installKeys(android.security.KeyStore keyStore,String name){
  boolean ret=true;
  String privKeyName=Credentials.USER_PRIVATE_KEY + name;
  String userCertName=Credentials.USER_CERTIFICATE + name;
  String caCertName=Credentials.CA_CERTIFICATE + name;
  if (mClientCertificate != null) {
    byte[] privKeyData=mClientPrivateKey.getEncoded();
    ret=keyStore.importKey(privKeyName,privKeyData,Process.WIFI_UID,KeyStore.FLAG_ENCRYPTED);
    if (ret == false) {
      return ret;
    }
    ret=putCertInKeyStore(keyStore,userCertName,mClientCertificate);
    if (ret == false) {
      keyStore.delKey(privKeyName,Process.WIFI_UID);
      return ret;
    }
  }
  if (mCaCert != null) {
    ret=putCertInKeyStore(keyStore,caCertName,mCaCert);
    if (ret == false) {
      if (mClientCertificate != null) {
        keyStore.delKey(privKeyName,Process.WIFI_UID);
        keyStore.delete(userCertName,Process.WIFI_UID);
      }
      return ret;
    }
  }
  if (mClientCertificate != null) {
    setClientCertificateAlias(name);
    mClientPrivateKey=null;
    mClientCertificate=null;
  }
  if (mCaCert != null) {
    setCaCertificateAlias(name);
    mCaCert=null;
  }
  return ret;
}

Fixed version (ground truth):
boolean installKeys(android.security.KeyStore keyStore,String name){
  boolean ret=true;
  String privKeyName=Credentials.USER_PRIVATE_KEY + name;
  String userCertName=Credentials.USER_CERTIFICATE + name;
  String caCertName=Credentials.CA_CERTIFICATE + name;
  if (mClientCertificate != null) {
    byte[] privKeyData=mClientPrivateKey.getEncoded();
    if (isHardwareBackedKey(mClientPrivateKey)) {
      if (DBG)       Slog.d(TAG,"String_Node_Str" + name + "String_Node_Str"+ "String_Node_Str");
      ret=keyStore.importKey(privKeyName,privKeyData,Process.WIFI_UID,KeyStore.FLAG_NONE);
    }
 else {
      if (DBG)       Slog.d(TAG,"String_Node_Str" + name + "String_Node_Str");
      ret=keyStore.importKey(privKeyName,privKeyData,Process.WIFI_UID,KeyStore.FLAG_ENCRYPTED);
      mNeedsSoftwareKeystore=true;
    }
    if (ret == false) {
      return ret;
    }
    ret=putCertInKeyStore(keyStore,userCertName,mClientCertificate);
    if (ret == false) {
      keyStore.delKey(privKeyName,Process.WIFI_UID);
      return ret;
    }
  }
  if (mCaCert != null) {
    ret=putCertInKeyStore(keyStore,caCertName,mCaCert);
    if (ret == false) {
      if (mClientCertificate != null) {
        keyStore.delKey(privKeyName,Process.WIFI_UID);
        keyStore.delete(userCertName,Process.WIFI_UID);
      }
      return ret;
    }
  }
  if (mClientCertificate != null) {
    setClientCertificateAlias(name);
    mClientPrivateKey=null;
    mClientCertificate=null;
  }
  if (mCaCert != null) {
    setCaCertificateAlias(name);
    mCaCert=null;
  }
  return ret;
}
Program: 1007
Project: 1007
Buggy source:
void removeKeys(KeyStore keyStore){
  String client=getFieldValue(CLIENT_CERT_KEY,CLIENT_CERT_PREFIX);
  if (!TextUtils.isEmpty(client)) {
    keyStore.delKey(Credentials.USER_PRIVATE_KEY + client,Process.WIFI_UID);
    keyStore.delete(Credentials.USER_CERTIFICATE + client,Process.WIFI_UID);
  }
  String ca=getFieldValue(CA_CERT_KEY,CA_CERT_PREFIX);
  if (!TextUtils.isEmpty(ca)) {
    keyStore.delete(Credentials.CA_CERTIFICATE + ca,Process.WIFI_UID);
  }
}

Fixed version (ground truth):
void removeKeys(KeyStore keyStore){
  String client=getFieldValue(CLIENT_CERT_KEY,CLIENT_CERT_PREFIX);
  if (!TextUtils.isEmpty(client)) {
    if (DBG)     Slog.d(TAG,"String_Node_Str");
    keyStore.delKey(Credentials.USER_PRIVATE_KEY + client,Process.WIFI_UID);
    keyStore.delete(Credentials.USER_CERTIFICATE + client,Process.WIFI_UID);
  }
  String ca=getFieldValue(CA_CERT_KEY,CA_CERT_PREFIX);
  if (!TextUtils.isEmpty(ca)) {
    if (DBG)     Slog.d(TAG,"String_Node_Str");
    keyStore.delete(Credentials.CA_CERTIFICATE + ca,Process.WIFI_UID);
  }
}
Program: 1008
Project: 1008
Buggy source:
private boolean putCertInKeyStore(android.security.KeyStore keyStore,String name,Certificate cert){
  try {
    byte[] certData=Credentials.convertToPem(cert);
    return keyStore.put(name,certData,Process.WIFI_UID,KeyStore.FLAG_ENCRYPTED);
  }
 catch (  IOException e1) {
    return false;
  }
catch (  CertificateException e2) {
    return false;
  }
}

Fixed version (ground truth):
private boolean putCertInKeyStore(android.security.KeyStore keyStore,String name,Certificate cert){
  try {
    byte[] certData=Credentials.convertToPem(cert);
    if (DBG)     Slog.d(TAG,"String_Node_Str" + name + "String_Node_Str");
    return keyStore.put(name,certData,Process.WIFI_UID,KeyStore.FLAG_NONE);
  }
 catch (  IOException e1) {
    return false;
  }
catch (  CertificateException e2) {
    return false;
  }
}
Program: 1009
Project: 1009
Buggy source:
@Override public void onReceive(Context context,Intent intent){
  String action=intent.getAction();
  if (action.equals(Intent.ACTION_SCREEN_ON)) {
    mWifiController.sendMessage(CMD_SCREEN_ON);
  }
 else   if (action.equals(Intent.ACTION_SCREEN_OFF)) {
    mWifiController.sendMessage(CMD_SCREEN_OFF);
  }
 else   if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
    int pluggedType=intent.getIntExtra("String_Node_Str",0);
    mWifiController.sendMessage(CMD_BATTERY_CHANGED,pluggedType,0,null);
  }
 else   if (action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
    int state=intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE,BluetoothAdapter.STATE_DISCONNECTED);
    mWifiStateMachine.sendBluetoothAdapterStateChange(state);
  }
 else   if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) {
    boolean emergencyMode=intent.getBooleanExtra("String_Node_Str",false);
    mWifiController.sendMessage(CMD_EMERGENCY_MODE_CHANGED,emergencyMode ? 1 : 0,0);
  }
}

Fixed version (ground truth):
@Override public void onReceive(Context context,Intent intent){
  String action=intent.getAction();
  if (action.equals(Intent.ACTION_SCREEN_ON)) {
    mWifiController.sendMessage(CMD_SCREEN_ON);
  }
 else   if (action.equals(Intent.ACTION_USER_PRESENT)) {
    mWifiController.sendMessage(CMD_USER_PRESENT);
  }
 else   if (action.equals(Intent.ACTION_SCREEN_OFF)) {
    mWifiController.sendMessage(CMD_SCREEN_OFF);
  }
 else   if (action.equals(Intent.ACTION_BATTERY_CHANGED)) {
    int pluggedType=intent.getIntExtra("String_Node_Str",0);
    mWifiController.sendMessage(CMD_BATTERY_CHANGED,pluggedType,0,null);
  }
 else   if (action.equals(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED)) {
    int state=intent.getIntExtra(BluetoothAdapter.EXTRA_CONNECTION_STATE,BluetoothAdapter.STATE_DISCONNECTED);
    mWifiStateMachine.sendBluetoothAdapterStateChange(state);
  }
 else   if (action.equals(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED)) {
    boolean emergencyMode=intent.getBooleanExtra("String_Node_Str",false);
    mWifiController.sendMessage(CMD_EMERGENCY_MODE_CHANGED,emergencyMode ? 1 : 0,0);
  }
}
Program: 1010
Project: 1010
Buggy source:
private void registerForBroadcasts(){
  IntentFilter intentFilter=new IntentFilter();
  intentFilter.addAction(Intent.ACTION_SCREEN_ON);
  intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
  intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
  intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
  intentFilter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
  intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
  mContext.registerReceiver(mReceiver,intentFilter);
}

Fixed version (ground truth):
private void registerForBroadcasts(){
  IntentFilter intentFilter=new IntentFilter();
  intentFilter.addAction(Intent.ACTION_SCREEN_ON);
  intentFilter.addAction(Intent.ACTION_USER_PRESENT);
  intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
  intentFilter.addAction(Intent.ACTION_BATTERY_CHANGED);
  intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);
  intentFilter.addAction(BluetoothAdapter.ACTION_CONNECTION_STATE_CHANGED);
  intentFilter.addAction(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED);
  mContext.registerReceiver(mReceiver,intentFilter);
}
Program: 1012
Project: 1012
Buggy source:
boolean installKeys(android.security.KeyStore keyStore,String name){
  boolean ret=true;
  String privKeyName=Credentials.USER_PRIVATE_KEY + name;
  String userCertName=Credentials.USER_CERTIFICATE + name;
  String caCertName=Credentials.CA_CERTIFICATE + name;
  if (mClientCertificate != null) {
    byte[] privKeyData=mClientPrivateKey.getEncoded();
    ret=keyStore.importKey(privKeyName,privKeyData,Process.WIFI_UID,KeyStore.FLAG_ENCRYPTED);
    if (ret == false) {
      return ret;
    }
    ret=putCertInKeyStore(keyStore,userCertName,mClientCertificate);
    if (ret == false) {
      keyStore.delKey(privKeyName,Process.WIFI_UID);
      return ret;
    }
  }
  if (mCaCert != null) {
    ret=putCertInKeyStore(keyStore,caCertName,mCaCert);
    if (ret == false) {
      if (mClientCertificate != null) {
        keyStore.delKey(privKeyName,Process.WIFI_UID);
        keyStore.delete(userCertName,Process.WIFI_UID);
      }
      return ret;
    }
  }
  if (mClientCertificate != null) {
    setClientCertificateAlias(name);
    mClientPrivateKey=null;
    mClientCertificate=null;
  }
  if (mCaCert != null) {
    setCaCertificateAlias(name);
    mCaCert=null;
  }
  return ret;
}

Fixed version (ground truth):
boolean installKeys(android.security.KeyStore keyStore,String name){
  boolean ret=true;
  String privKeyName=Credentials.USER_PRIVATE_KEY + name;
  String userCertName=Credentials.USER_CERTIFICATE + name;
  String caCertName=Credentials.CA_CERTIFICATE + name;
  if (mClientCertificate != null) {
    byte[] privKeyData=mClientPrivateKey.getEncoded();
    if (isHardwareBackedKey(mClientPrivateKey)) {
      if (DBG)       Slog.d(TAG,"String_Node_Str" + name + "String_Node_Str"+ "String_Node_Str");
      ret=keyStore.importKey(privKeyName,privKeyData,Process.WIFI_UID,KeyStore.FLAG_NONE);
    }
 else {
      if (DBG)       Slog.d(TAG,"String_Node_Str" + name + "String_Node_Str");
      ret=keyStore.importKey(privKeyName,privKeyData,Process.WIFI_UID,KeyStore.FLAG_ENCRYPTED);
      mNeedsSoftwareKeystore=true;
    }
    if (ret == false) {
      return ret;
    }
    ret=putCertInKeyStore(keyStore,userCertName,mClientCertificate);
    if (ret == false) {
      keyStore.delKey(privKeyName,Process.WIFI_UID);
      return ret;
    }
  }
  if (mCaCert != null) {
    ret=putCertInKeyStore(keyStore,caCertName,mCaCert);
    if (ret == false) {
      if (mClientCertificate != null) {
        keyStore.delKey(privKeyName,Process.WIFI_UID);
        keyStore.delete(userCertName,Process.WIFI_UID);
      }
      return ret;
    }
  }
  if (mClientCertificate != null) {
    setClientCertificateAlias(name);
    mClientPrivateKey=null;
    mClientCertificate=null;
  }
  if (mCaCert != null) {
    setCaCertificateAlias(name);
    mCaCert=null;
  }
  return ret;
}
Program: 1013
Project: 1013
Buggy source:
void removeKeys(KeyStore keyStore){
  String client=getFieldValue(CLIENT_CERT_KEY,CLIENT_CERT_PREFIX);
  if (!TextUtils.isEmpty(client)) {
    keyStore.delKey(Credentials.USER_PRIVATE_KEY + client,Process.WIFI_UID);
    keyStore.delete(Credentials.USER_CERTIFICATE + client,Process.WIFI_UID);
  }
  String ca=getFieldValue(CA_CERT_KEY,CA_CERT_PREFIX);
  if (!TextUtils.isEmpty(ca)) {
    keyStore.delete(Credentials.CA_CERTIFICATE + ca,Process.WIFI_UID);
  }
}

Fixed version (ground truth):
void removeKeys(KeyStore keyStore){
  String client=getFieldValue(CLIENT_CERT_KEY,CLIENT_CERT_PREFIX);
  if (!TextUtils.isEmpty(client)) {
    if (DBG)     Slog.d(TAG,"String_Node_Str");
    keyStore.delKey(Credentials.USER_PRIVATE_KEY + client,Process.WIFI_UID);
    keyStore.delete(Credentials.USER_CERTIFICATE + client,Process.WIFI_UID);
  }
  String ca=getFieldValue(CA_CERT_KEY,CA_CERT_PREFIX);
  if (!TextUtils.isEmpty(ca)) {
    if (DBG)     Slog.d(TAG,"String_Node_Str");
    keyStore.delete(Credentials.CA_CERTIFICATE + ca,Process.WIFI_UID);
  }
}
Program: 1014
Project: 1014
Buggy source:
private boolean putCertInKeyStore(android.security.KeyStore keyStore,String name,Certificate cert){
  try {
    byte[] certData=Credentials.convertToPem(cert);
    return keyStore.put(name,certData,Process.WIFI_UID,KeyStore.FLAG_ENCRYPTED);
  }
 catch (  IOException e1) {
    return false;
  }
catch (  CertificateException e2) {
    return false;
  }
}

Fixed version (ground truth):
private boolean putCertInKeyStore(android.security.KeyStore keyStore,String name,Certificate cert){
  try {
    byte[] certData=Credentials.convertToPem(cert);
    if (DBG)     Slog.d(TAG,"String_Node_Str" + name + "String_Node_Str");
    return keyStore.put(name,certData,Process.WIFI_UID,KeyStore.FLAG_NONE);
  }
 catch (  IOException e1) {
    return false;
  }
catch (  CertificateException e2) {
    return false;
  }
}
Program: 1015
Project: 1015
Buggy source:
@Override public boolean bindService(Intent service,ServiceConnection conn,int flags){
  warnIfCallingFromSystemProcess();
  return bindServiceAsUser(service,conn,flags,Process.myUserHandle());
}

Fixed version (ground truth):
@Override public boolean bindService(Intent service,ServiceConnection conn,int flags){
  warnIfCallingFromSystemProcess();
  return bindServiceCommon(service,conn,flags,Process.myUserHandle());
}
Program: 1016
Project: 1016
Buggy source:
@Override public ComponentName startServiceAsUser(Intent service,UserHandle user){
  try {
    if (service.getComponent() == null && service.getPackage() == null) {
      if (getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.KITKAT) {
        IllegalArgumentException ex=new IllegalArgumentException("String_Node_Str" + service);
        Log.e(TAG,"String_Node_Str",ex);
      }
    }
    service.prepareToLeaveProcess();
    ComponentName cn=ActivityManagerNative.getDefault().startService(mMainThread.getApplicationThread(),service,service.resolveTypeIfNeeded(getContentResolver()),user.getIdentifier());
    if (cn != null) {
      if (cn.getPackageName().equals("String_Node_Str")) {
        throw new SecurityException("String_Node_Str" + service + "String_Node_Str"+ cn.getClassName());
      }
 else       if (cn.getPackageName().equals("String_Node_Str")) {
        throw new SecurityException("String_Node_Str" + service + "String_Node_Str"+ cn.getClassName());
      }
    }
    return cn;
  }
 catch (  RemoteException e) {
    return null;
  }
}

Fixed version (ground truth):
@Override public ComponentName startServiceAsUser(Intent service,UserHandle user){
  return startServiceCommon(service,user);
}
Program: 1017
Project: 1017
Buggy source:
@Override public boolean stopServiceAsUser(Intent service,UserHandle user){
  try {
    if (service.getComponent() == null && service.getPackage() == null) {
      if (getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.KITKAT) {
        IllegalArgumentException ex=new IllegalArgumentException("String_Node_Str" + service);
        Log.e(TAG,"String_Node_Str",ex);
      }
    }
    service.prepareToLeaveProcess();
    int res=ActivityManagerNative.getDefault().stopService(mMainThread.getApplicationThread(),service,service.resolveTypeIfNeeded(getContentResolver()),user.getIdentifier());
    if (res < 0) {
      throw new SecurityException("String_Node_Str" + service);
    }
    return res != 0;
  }
 catch (  RemoteException e) {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean stopServiceAsUser(Intent service,UserHandle user){
  return stopServiceCommon(service,user);
}
Program: 1018
Project: 1018
Buggy source:
/** 
 * @hide 
 */
@Override public boolean bindServiceAsUser(Intent service,ServiceConnection conn,int flags,UserHandle user){
  IServiceConnection sd;
  if (conn == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  if (mPackageInfo != null) {
    sd=mPackageInfo.getServiceDispatcher(conn,getOuterContext(),mMainThread.getHandler(),flags);
  }
 else {
    throw new RuntimeException("String_Node_Str");
  }
  if (service.getComponent() == null && service.getPackage() == null) {
    if (getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.KITKAT) {
      IllegalArgumentException ex=new IllegalArgumentException("String_Node_Str" + service);
      Log.e(TAG,"String_Node_Str",ex);
    }
  }
  try {
    IBinder token=getActivityToken();
    if (token == null && (flags & BIND_AUTO_CREATE) == 0 && mPackageInfo != null && mPackageInfo.getApplicationInfo().targetSdkVersion < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
      flags|=BIND_WAIVE_PRIORITY;
    }
    service.prepareToLeaveProcess();
    int res=ActivityManagerNative.getDefault().bindService(mMainThread.getApplicationThread(),getActivityToken(),service,service.resolveTypeIfNeeded(getContentResolver()),sd,flags,user.getIdentifier());
    if (res < 0) {
      throw new SecurityException("String_Node_Str" + service);
    }
    return res != 0;
  }
 catch (  RemoteException e) {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * @hide 
 */
@Override public boolean bindServiceAsUser(Intent service,ServiceConnection conn,int flags,UserHandle user){
  return bindServiceCommon(service,conn,flags,user);
}
Program: 1019
Project: 1019
Buggy source:
@Override public ComponentName startService(Intent service){
  warnIfCallingFromSystemProcess();
  return startServiceAsUser(service,mUser);
}

Fixed version (ground truth):
@Override public ComponentName startService(Intent service){
  warnIfCallingFromSystemProcess();
  return startServiceCommon(service,mUser);
}
Program: 1020
Project: 1020
Buggy source:
@Override public boolean stopService(Intent service){
  warnIfCallingFromSystemProcess();
  return stopServiceAsUser(service,mUser);
}

Fixed version (ground truth):
@Override public boolean stopService(Intent service){
  warnIfCallingFromSystemProcess();
  return stopServiceCommon(service,mUser);
}