Program: 23914
Project: 23914
Buggy source:
void readStateFromFileLocked(File file){
  FileInputStream stream=null;
  boolean success=false;
  try {
    stream=new FileInputStream(file);
    XmlPullParser parser=Xml.newPullParser();
    parser.setInput(stream,null);
    int type;
    int providerIndex=0;
    HashMap<Integer,Provider> loadedProviders=new HashMap<Integer,Provider>();
    do {
      type=parser.next();
      if (type == XmlPullParser.START_TAG) {
        String tag=parser.getName();
        if ("String_Node_Str".equals(tag)) {
          String pkg=parser.getAttributeValue(null,"String_Node_Str");
          String cl=parser.getAttributeValue(null,"String_Node_Str");
          Provider p=lookupProviderLocked(new ComponentName(pkg,cl));
          if (p == null && mSafeMode) {
            p=new Provider();
            p.info=new AppWidgetProviderInfo();
            p.info.provider=new ComponentName(pkg,cl);
            p.zombie=true;
            mInstalledProviders.add(p);
          }
          if (p != null) {
            loadedProviders.put(providerIndex,p);
          }
          providerIndex++;
        }
 else         if ("String_Node_Str".equals(tag)) {
          Host host=new Host();
          host.packageName=parser.getAttributeValue(null,"String_Node_Str");
          try {
            host.uid=getUidForPackage(host.packageName);
          }
 catch (          PackageManager.NameNotFoundException ex) {
            host.zombie=true;
          }
          if (!host.zombie || mSafeMode) {
            host.hostId=Integer.parseInt(parser.getAttributeValue(null,"String_Node_Str"),16);
            mHosts.add(host);
          }
        }
 else         if ("String_Node_Str".equals(tag)) {
          AppWidgetId id=new AppWidgetId();
          id.appWidgetId=Integer.parseInt(parser.getAttributeValue(null,"String_Node_Str"),16);
          if (id.appWidgetId >= mNextAppWidgetId) {
            mNextAppWidgetId=id.appWidgetId + 1;
          }
          String providerString=parser.getAttributeValue(null,"String_Node_Str");
          if (providerString != null) {
            int pIndex=Integer.parseInt(providerString,16);
            id.provider=loadedProviders.get(pIndex);
            if (false) {
              Log.d(TAG,"String_Node_Str" + id.appWidgetId + "String_Node_Str"+ pIndex+ "String_Node_Str"+ id.provider);
            }
            if (id.provider == null) {
              continue;
            }
          }
          int hIndex=Integer.parseInt(parser.getAttributeValue(null,"String_Node_Str"),16);
          id.host=mHosts.get(hIndex);
          if (id.host == null) {
            continue;
          }
          if (id.provider != null) {
            id.provider.instances.add(id);
          }
          id.host.instances.add(id);
          mAppWidgetIds.add(id);
        }
      }
    }
 while (type != XmlPullParser.END_DOCUMENT);
    success=true;
  }
 catch (  NullPointerException e) {
    Log.w(TAG,"String_Node_Str" + file,e);
  }
catch (  NumberFormatException e) {
    Log.w(TAG,"String_Node_Str" + file,e);
  }
catch (  XmlPullParserException e) {
    Log.w(TAG,"String_Node_Str" + file,e);
  }
catch (  IOException e) {
    Log.w(TAG,"String_Node_Str" + file,e);
  }
catch (  IndexOutOfBoundsException e) {
    Log.w(TAG,"String_Node_Str" + file,e);
  }
  try {
    if (stream != null) {
      stream.close();
    }
  }
 catch (  IOException e) {
  }
  if (success) {
    final int N=mHosts.size();
    for (int i=0; i < N; i++) {
      pruneHostLocked(mHosts.get(i));
    }
  }
 else {
    mAppWidgetIds.clear();
    mHosts.clear();
    final int N=mInstalledProviders.size();
    for (int i=0; i < N; i++) {
      mInstalledProviders.get(i).instances.clear();
    }
  }
}

Fixed version (ground truth):
void readStateFromFileLocked(File file){
  FileInputStream stream=null;
  boolean success=false;
  try {
    stream=new FileInputStream(file);
    XmlPullParser parser=Xml.newPullParser();
    parser.setInput(stream,null);
    int type;
    int providerIndex=0;
    HashMap<Integer,Provider> loadedProviders=new HashMap<Integer,Provider>();
    do {
      type=parser.next();
      if (type == XmlPullParser.START_TAG) {
        String tag=parser.getName();
        if ("String_Node_Str".equals(tag)) {
          String pkg=parser.getAttributeValue(null,"String_Node_Str");
          String cl=parser.getAttributeValue(null,"String_Node_Str");
          Provider p=lookupProviderLocked(new ComponentName(pkg,cl));
          if (p == null && mSafeMode) {
            p=new Provider();
            p.info=new AppWidgetProviderInfo();
            p.info.provider=new ComponentName(pkg,cl);
            p.zombie=true;
            mInstalledProviders.add(p);
          }
          if (p != null) {
            loadedProviders.put(providerIndex,p);
          }
          providerIndex++;
        }
 else         if ("String_Node_Str".equals(tag)) {
          Host host=new Host();
          host.packageName=parser.getAttributeValue(null,"String_Node_Str");
          try {
            host.uid=getUidForPackage(host.packageName);
          }
 catch (          PackageManager.NameNotFoundException ex) {
            host.zombie=true;
          }
          if (!host.zombie || mSafeMode) {
            host.hostId=Integer.parseInt(parser.getAttributeValue(null,"String_Node_Str"),16);
            mHosts.add(host);
          }
        }
 else         if ("String_Node_Str".equals(tag)) {
          AppWidgetId id=new AppWidgetId();
          id.appWidgetId=Integer.parseInt(parser.getAttributeValue(null,"String_Node_Str"),16);
          if (id.appWidgetId >= mNextAppWidgetId) {
            mNextAppWidgetId=id.appWidgetId + 1;
          }
          String providerString=parser.getAttributeValue(null,"String_Node_Str");
          if (providerString != null) {
            int pIndex=Integer.parseInt(providerString,16);
            id.provider=loadedProviders.get(pIndex);
            if (false) {
              Log.d(TAG,"String_Node_Str" + id.appWidgetId + "String_Node_Str"+ pIndex+ "String_Node_Str"+ id.provider);
            }
            if (id.provider == null) {
              continue;
            }
          }
          int hIndex=Integer.parseInt(parser.getAttributeValue(null,"String_Node_Str"),16);
          id.host=mHosts.get(hIndex);
          if (id.host == null) {
            continue;
          }
          if (id.provider != null) {
            id.provider.instances.add(id);
          }
          id.host.instances.add(id);
          mAppWidgetIds.add(id);
        }
      }
    }
 while (type != XmlPullParser.END_DOCUMENT);
    success=true;
  }
 catch (  NullPointerException e) {
    Log.w(TAG,"String_Node_Str" + file,e);
  }
catch (  NumberFormatException e) {
    Log.w(TAG,"String_Node_Str" + file,e);
  }
catch (  XmlPullParserException e) {
    Log.w(TAG,"String_Node_Str" + file,e);
  }
catch (  IOException e) {
    Log.w(TAG,"String_Node_Str" + file,e);
  }
catch (  IndexOutOfBoundsException e) {
    Log.w(TAG,"String_Node_Str" + file,e);
  }
  try {
    if (stream != null) {
      stream.close();
    }
  }
 catch (  IOException e) {
  }
  if (success) {
    for (int i=mHosts.size() - 1; i >= 0; i--) {
      pruneHostLocked(mHosts.get(i));
    }
  }
 else {
    mAppWidgetIds.clear();
    mHosts.clear();
    final int N=mInstalledProviders.size();
    for (int i=0; i < N; i++) {
      mInstalledProviders.get(i).instances.clear();
    }
  }
}