Program: 182221
Project: 182221
Buggy source:
boolean restoreNamedResourceLocked(){
  if (mName.length() > 4 && "String_Node_Str".equals(mName.substring(0,4))) {
    String resName=mName.substring(4);
    String pkg=null;
    int colon=resName.indexOf(':');
    if (colon > 0) {
      pkg=resName.substring(0,colon);
    }
    String ident=null;
    int slash=resName.lastIndexOf('/');
    if (slash > 0) {
      ident=resName.substring(slash + 1);
    }
    String type=null;
    if (colon > 0 && slash > 0 && (slash - colon) > 1) {
      type=resName.substring(colon + 1,slash);
    }
    if (pkg != null && ident != null && type != null) {
      int resId=-1;
      InputStream res=null;
      FileOutputStream fos=null;
      try {
        Context c=mContext.createPackageContext(pkg,Context.CONTEXT_RESTRICTED);
        Resources r=c.getResources();
        resId=r.getIdentifier(resName,null,null);
        if (resId == 0) {
          Slog.e(TAG,"String_Node_Str" + pkg + "String_Node_Str"+ type+ "String_Node_Str"+ ident);
          return false;
        }
        res=r.openRawResource(resId);
        fos=new FileOutputStream(WALLPAPER_FILE);
        byte[] buffer=new byte[32768];
        int amt;
        while ((amt=res.read(buffer)) > 0) {
          fos.write(buffer,0,amt);
        }
        Slog.v(TAG,"String_Node_Str" + resName);
        return true;
      }
 catch (      NameNotFoundException e) {
        Slog.e(TAG,"String_Node_Str" + pkg + "String_Node_Str");
      }
catch (      Resources.NotFoundException e) {
        Slog.e(TAG,"String_Node_Str" + resId);
      }
catch (      IOException e) {
        Slog.e(TAG,"String_Node_Str",e);
      }
 finally {
        if (res != null) {
          try {
            res.close();
          }
 catch (          IOException ex) {
          }
        }
        if (fos != null) {
          try {
            fos.close();
          }
 catch (          IOException ex) {
          }
        }
      }
    }
  }
  return false;
}

Fixed version (ground truth):
boolean restoreNamedResourceLocked(){
  if (mName.length() > 4 && "String_Node_Str".equals(mName.substring(0,4))) {
    String resName=mName.substring(4);
    String pkg=null;
    int colon=resName.indexOf(':');
    if (colon > 0) {
      pkg=resName.substring(0,colon);
    }
    String ident=null;
    int slash=resName.lastIndexOf('/');
    if (slash > 0) {
      ident=resName.substring(slash + 1);
    }
    String type=null;
    if (colon > 0 && slash > 0 && (slash - colon) > 1) {
      type=resName.substring(colon + 1,slash);
    }
    if (pkg != null && ident != null && type != null) {
      int resId=-1;
      InputStream res=null;
      FileOutputStream fos=null;
      try {
        Context c=mContext.createPackageContext(pkg,Context.CONTEXT_RESTRICTED);
        Resources r=c.getResources();
        resId=r.getIdentifier(resName,null,null);
        if (resId == 0) {
          Slog.e(TAG,"String_Node_Str" + pkg + "String_Node_Str"+ type+ "String_Node_Str"+ ident);
          return false;
        }
        res=r.openRawResource(resId);
        if (WALLPAPER_FILE.exists()) {
          WALLPAPER_FILE.delete();
        }
        fos=new FileOutputStream(WALLPAPER_FILE);
        byte[] buffer=new byte[32768];
        int amt;
        while ((amt=res.read(buffer)) > 0) {
          fos.write(buffer,0,amt);
        }
        Slog.v(TAG,"String_Node_Str" + resName);
        return true;
      }
 catch (      NameNotFoundException e) {
        Slog.e(TAG,"String_Node_Str" + pkg + "String_Node_Str");
      }
catch (      Resources.NotFoundException e) {
        Slog.e(TAG,"String_Node_Str" + resId);
      }
catch (      IOException e) {
        Slog.e(TAG,"String_Node_Str",e);
      }
 finally {
        if (res != null) {
          try {
            res.close();
          }
 catch (          IOException ex) {
          }
        }
        if (fos != null) {
          try {
            fos.close();
          }
 catch (          IOException ex) {
          }
        }
      }
    }
  }
  return false;
}