Program: 54276
Project: 54276
Buggy source:
@Override protected void onActivityResult(int request,int result,Intent intent){
  super.onActivityResult(request,result,intent);
  if (request == SELECT_PICTURE && result == RESULT_OK) {
    try {
      Uri uri=intent.getData();
      String fileName=null, mimeType=null;
      if (uri != null) {
        String[] columns={MediaColumns.DATA};
        Cursor cursor=getContentResolver().query(uri,columns,null,null,null);
        cursor.moveToFirst();
        int index=cursor.getColumnIndex(MediaColumns.DATA);
        if (index != -1) {
          fileName=cursor.getString(index);
        }
        cursor.close();
      }
      if (fileName == null) {
        setStoppedState();
        new ErrorDialog("String_Node_Str","String_Node_Str",MITM.this).show();
      }
 else {
        mimeType=System.getImageMimeType(fileName);
        mSpoofSession=new SpoofSession(true,true,fileName,mimeType);
        if (mCurrentActivity != null)         mCurrentActivity.setVisibility(View.VISIBLE);
        mSpoofSession.start(new OnSessionReadyListener(){
          @Override public void onSessionReady(){
            MITM.this.runOnUiThread(new Runnable(){
              @Override public void run(){
                System.getProxy().setFilter(new Proxy.ProxyFilter(){
                  @Override public String onDataReceived(                  String headers,                  String data){
                    String resource=System.getServer().getResourceURL();
                    data=data.replaceAll("String_Node_Str","String_Node_Str" + resource + "String_Node_Str");
                    data=data.replaceAll("String_Node_Str","String_Node_Str" + resource + "String_Node_Str");
                    return data;
                  }
                }
);
                Toast.makeText(MITM.this,"String_Node_Str",Toast.LENGTH_LONG).show();
              }
            }
);
          }
        }
);
      }
    }
 catch (    Exception e) {
      System.errorLogging(TAG,e);
    }
  }
 else   if (request == SELECT_SCRIPT && result == RESULT_OK) {
    String fileName=null;
    if (intent != null && intent.getData() != null)     fileName=intent.getData().getPath();
    if (fileName == null) {
      new ErrorDialog("String_Node_Str","String_Node_Str",MITM.this).show();
    }
 else {
      try {
        StringBuffer buffer=new StringBuffer();
        BufferedReader reader=new BufferedReader(new FileReader(fileName));
        char[] buf=new char[1024];
        int read=0;
        String js="String_Node_Str";
        while ((read=reader.read(buf)) != -1) {
          buffer.append(String.valueOf(buf,0,read));
        }
        reader.close();
        js=buffer.toString().trim();
        if (js.startsWith("String_Node_Str") == false && js.startsWith("String_Node_Str") == false)         js="String_Node_Str" + js + "String_Node_Str";
        mCurrentActivity.setVisibility(View.VISIBLE);
        Toast.makeText(MITM.this,"String_Node_Str",Toast.LENGTH_LONG).show();
        final String code=js;
        mSpoofSession=new SpoofSession();
        mSpoofSession.start(new OnSessionReadyListener(){
          @Override public void onSessionReady(){
            System.getProxy().setFilter(new Proxy.ProxyFilter(){
              @Override public String onDataReceived(              String headers,              String data){
                return data.replaceAll("String_Node_Str",code + "String_Node_Str");
              }
            }
);
          }
        }
);
      }
 catch (      Exception e) {
        new ErrorDialog("String_Node_Str","String_Node_Str" + e.getMessage(),MITM.this).show();
      }
    }
  }
 else   if (request == SettingsActivity.SETTINGS_DONE) {
    checkForOpenPorts();
  }
}

Fixed version (ground truth):
@Override protected void onActivityResult(int request,int result,Intent intent){
  super.onActivityResult(request,result,intent);
  if (request == SELECT_PICTURE && result == RESULT_OK) {
    try {
      Uri uri=intent.getData();
      String fileName=null, mimeType=null;
      if (uri != null) {
        String[] columns={MediaColumns.DATA};
        Cursor cursor=getContentResolver().query(uri,columns,null,null,null);
        cursor.moveToFirst();
        int index=cursor.getColumnIndex(MediaColumns.DATA);
        if (index != -1) {
          fileName=cursor.getString(index);
        }
        cursor.close();
      }
      if (fileName == null) {
        setStoppedState();
        new ErrorDialog("String_Node_Str","String_Node_Str",MITM.this).show();
      }
 else {
        mimeType=System.getImageMimeType(fileName);
        mSpoofSession=new SpoofSession(true,true,fileName,mimeType);
        if (mCurrentActivity != null)         mCurrentActivity.setVisibility(View.VISIBLE);
        mSpoofSession.start(new OnSessionReadyListener(){
          @Override public void onSessionReady(){
            MITM.this.runOnUiThread(new Runnable(){
              @Override public void run(){
                System.getProxy().setFilter(new Proxy.ProxyFilter(){
                  @Override public String onDataReceived(                  String headers,                  String data){
                    String resource=System.getServer().getResourceURL();
                    data=data.replaceAll("String_Node_Str","String_Node_Str" + resource + "String_Node_Str");
                    data=data.replaceAll("String_Node_Str","String_Node_Str" + resource + "String_Node_Str");
                    return data;
                  }
                }
);
                Toast.makeText(MITM.this,"String_Node_Str",Toast.LENGTH_LONG).show();
              }
            }
);
          }
        }
);
      }
    }
 catch (    Exception e) {
      System.errorLogging(TAG,e);
    }
  }
 else   if (request == SELECT_SCRIPT && result == RESULT_OK) {
    String fileName=null;
    if (intent != null && intent.getData() != null)     fileName=intent.getData().getPath();
    if (fileName == null) {
      new ErrorDialog("String_Node_Str","String_Node_Str",MITM.this).show();
    }
 else {
      try {
        StringBuffer buffer=new StringBuffer();
        BufferedReader reader=new BufferedReader(new FileReader(fileName));
        char[] buf=new char[1024];
        int read=0;
        String js="String_Node_Str";
        while ((read=reader.read(buf)) != -1) {
          buffer.append(String.valueOf(buf,0,read));
        }
        reader.close();
        js=buffer.toString().trim();
        if (js.startsWith("String_Node_Str") == false && js.startsWith("String_Node_Str") == false)         js="String_Node_Str" + js + "String_Node_Str";
        mCurrentActivity.setVisibility(View.VISIBLE);
        Toast.makeText(MITM.this,"String_Node_Str",Toast.LENGTH_LONG).show();
        final String code=js;
        mSpoofSession=new SpoofSession();
        mSpoofSession.start(new OnSessionReadyListener(){
          @Override public void onSessionReady(){
            System.getProxy().setFilter(new Proxy.ProxyFilter(){
              @Override public String onDataReceived(              String headers,              String data){
                return data.replaceAll("String_Node_Str",code + "String_Node_Str");
              }
            }
);
          }
        }
);
      }
 catch (      Exception e) {
        new ErrorDialog("String_Node_Str","String_Node_Str" + e.getMessage(),MITM.this).show();
      }
    }
  }
 else   if (request == SettingsActivity.SETTINGS_DONE) {
    new CheckForOpenPortsTask().execute();
  }
}