Program: 17537
Project: 17537
Buggy source:
protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  Const.FilesDir=mContext.getFilesDir();
  Const.RecoveryCollectionFile=new File(Const.FilesDir,"String_Node_Str");
  Const.KernelCollectionFile=new File(Const.FilesDir,"String_Node_Str");
  isDark=Common.getBooleanPref(mContext,Const.PREF_NAME,Const.PREF_KEY_DARK_UI);
  setTheme(!isDark ? R.style.Rashr : R.style.Rashr_Dark);
  setContentView(R.layout.loading_layout);
  final TextView tvLoading=(TextView)findViewById(R.id.tvLoading);
  final Thread StartThread=new Thread(new Runnable(){
    @Override public void run(){
      final int previous_version=Common.getIntegerPref(mContext,Const.PREF_NAME,Const.PREF_KEY_CUR_VER);
      final int current_version=BuildConfig.VERSION_CODE;
      mVersionChanged=current_version > previous_version;
      Common.setIntegerPref(mContext,Const.PREF_NAME,Const.PREF_KEY_CUR_VER,current_version);
      try {
        startShell();
      }
 catch (      IOException e) {
        mActivity.addError(Const.RASHR_TAG,e,false);
        mActivity.runOnUiThread(new Runnable(){
          @Override public void run(){
            setContentView(R.layout.err_layout);
          }
        }
);
        return;
      }
      Common.deleteLogs(mContext);
      mActivity.runOnUiThread(new Runnable(){
        @Override public void run(){
          tvLoading.setText(R.string.loading_data);
        }
      }
);
      for (      File i : Folder) {
        if (!i.exists()) {
          if (!i.mkdir()) {
            mActivity.addError(Const.RASHR_TAG,new IOException(i + "String_Node_Str"),false);
          }
        }
      }
      try {
        extractFiles();
      }
 catch (      IOException e) {
        mActivity.addError(Const.RASHR_TAG,e,true);
        mActivity.runOnUiThread(new Runnable(){
          @Override public void run(){
            Toast.makeText(mContext,R.string.failed_unpack_files,Toast.LENGTH_LONG).show();
          }
        }
);
      }
      try {
        File LogCopy=new File(mContext.getFilesDir(),Const.LastLog.getName() + "String_Node_Str");
        mShell.execCommand(Const.Busybox + "String_Node_Str" + Const.LastLog);
        LogCopy.delete();
        mToolbox.copyFile(Const.LastLog,LogCopy,false,false);
        mShell.execCommand(Const.Busybox + "String_Node_Str" + LogCopy);
        LastLogExists=LogCopy.exists();
      }
 catch (      Exception e) {
        mActivity.addError(Const.RASHR_TAG,e,false);
      }
      mActivity.runOnUiThread(new Runnable(){
        @Override public void run(){
          checkUpdates(current_version);
          tvLoading.setText(R.string.reading_device);
        }
      }
);
      if (mDevice == null)       mDevice=new Device(mActivity);
      if (!mDevice.isRecoverySupported() && !mDevice.isKernelSupported()) {
        mActivity.runOnUiThread(new Runnable(){
          @Override public void run(){
            showDeviceNotSupportedDialog();
          }
        }
);
      }
 else {
        Common.setBooleanPref(mContext,Const.PREF_NAME,Const.PREF_KEY_SHOW_UNIFIED,true);
        if (!Common.getBooleanPref(mContext,Const.PREF_NAME,Const.PREF_KEY_FIRST_RUN)) {
          Common.setBooleanPref(mContext,Const.PREF_NAME,Const.PREF_KEY_HIDE_UPDATE_HINTS,false);
          Common.setBooleanPref(mContext,Const.PREF_NAME,Const.PREF_KEY_ADS,true);
          Common.setBooleanPref(mContext,Shell.PREF_NAME,Shell.PREF_LOG,true);
          Common.setBooleanPref(mContext,Const.PREF_NAME,Const.PREF_KEY_CHECK_UPDATES,true);
          mActivity.runOnUiThread(new Runnable(){
            @Override public void run(){
              showUsageWarning();
            }
          }
);
        }
      }
      mActivity.runOnUiThread(new Runnable(){
        @Override public void run(){
          try {
            setContentView(R.layout.activity_rashr);
            mToolbar=(Toolbar)findViewById(R.id.toolbar);
            setSupportActionBar(mToolbar);
            mNavigationDrawerFragment=(NavigationDrawerFragment)getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
            mNavigationDrawerFragment.setUp(R.id.navigation_drawer,(DrawerLayout)findViewById(R.id.RashrLayout));
            AdView ads=(AdView)findViewById(R.id.ads);
            if (ads != null) {
              if (Common.getBooleanPref(mContext,Const.PREF_NAME,Const.PREF_KEY_ADS)) {
                ads.loadAd(new AdRequest().addTestDevice("String_Node_Str"));
              }
            }
            if (getIntent().getAction().equals(Intent.ACTION_VIEW)) {
              if (getIntent().getData().toString().endsWith("String_Node_Str")) {
                File zip=new File(getIntent().getData().getPath());
                if (zip.exists())                 switchTo(ScriptManagerFragment.newInstance(mActivity,zip));
              }
 else {
                File img=new File(getIntent().getData().getPath());
                if (img.exists())                 switchTo(FlashAsFragment.newInstance(mActivity,img,true));
              }
            }
 else {
              onNavigationDrawerItemSelected(0);
            }
          }
 catch (          NullPointerException e) {
            setContentView(R.layout.err_layout);
            mActivity.addError(Const.RASHR_TAG,e,false);
            AppCompatTextView tv=(AppCompatTextView)findViewById(R.id.tvErr);
            try {
              tv.setText(R.string.failed_setup_layout);
            }
 catch (            RuntimeException ex) {
              mActivity.addError(Const.RASHR_TAG,e,true);
              ex.printStackTrace();
            }
          }
        }
      }
);
    }
  }
);
  StartThread.start();
}

Fixed version (ground truth):
protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  Const.FilesDir=mContext.getFilesDir();
  Const.RecoveryCollectionFile=new File(Const.FilesDir,"String_Node_Str");
  Const.KernelCollectionFile=new File(Const.FilesDir,"String_Node_Str");
  isDark=Common.getBooleanPref(mContext,Const.PREF_NAME,Const.PREF_KEY_DARK_UI);
  setTheme(!isDark ? R.style.Rashr : R.style.Rashr_Dark);
  setContentView(R.layout.loading_layout);
  final TextView tvLoading=(TextView)findViewById(R.id.tvLoading);
  final Thread StartThread=new Thread(new Runnable(){
    @Override public void run(){
      final int previous_version=Common.getIntegerPref(mContext,Const.PREF_NAME,Const.PREF_KEY_CUR_VER);
      final int current_version=BuildConfig.VERSION_CODE;
      mVersionChanged=current_version > previous_version;
      Common.setIntegerPref(mContext,Const.PREF_NAME,Const.PREF_KEY_CUR_VER,current_version);
      try {
        startShell();
      }
 catch (      IOException e) {
        mActivity.addError(Const.RASHR_TAG,e,false);
        mActivity.runOnUiThread(new Runnable(){
          @Override public void run(){
            setContentView(R.layout.err_layout);
          }
        }
);
        return;
      }
      Common.deleteLogs(mContext);
      mActivity.runOnUiThread(new Runnable(){
        @Override public void run(){
          tvLoading.setText(R.string.loading_data);
        }
      }
);
      if (Const.PathToTmp.exists()) {
        Common.deleteFolder(Const.PathToTmp,true);
      }
      for (      File i : Folder) {
        if (!i.exists()) {
          if (!i.mkdir()) {
            mActivity.addError(Const.RASHR_TAG,new IOException(i + "String_Node_Str"),false);
          }
        }
      }
      try {
        extractFiles();
      }
 catch (      IOException e) {
        mActivity.addError(Const.RASHR_TAG,e,true);
        mActivity.runOnUiThread(new Runnable(){
          @Override public void run(){
            Toast.makeText(mContext,R.string.failed_unpack_files,Toast.LENGTH_LONG).show();
          }
        }
);
      }
      try {
        File LogCopy=new File(mContext.getFilesDir(),Const.LastLog.getName() + "String_Node_Str");
        mShell.execCommand(Const.Busybox + "String_Node_Str" + Const.LastLog);
        LogCopy.delete();
        mToolbox.copyFile(Const.LastLog,LogCopy,false,false);
        mShell.execCommand(Const.Busybox + "String_Node_Str" + LogCopy);
        LastLogExists=LogCopy.exists();
      }
 catch (      Exception e) {
        mActivity.addError(Const.RASHR_TAG,e,false);
      }
      mActivity.runOnUiThread(new Runnable(){
        @Override public void run(){
          checkUpdates(current_version);
          tvLoading.setText(R.string.reading_device);
        }
      }
);
      if (mDevice == null)       mDevice=new Device(mActivity);
      if (!mDevice.isRecoverySupported() && !mDevice.isKernelSupported()) {
        mActivity.runOnUiThread(new Runnable(){
          @Override public void run(){
            showDeviceNotSupportedDialog();
          }
        }
);
      }
 else {
        Common.setBooleanPref(mContext,Const.PREF_NAME,Const.PREF_KEY_SHOW_UNIFIED,true);
        if (!Common.getBooleanPref(mContext,Const.PREF_NAME,Const.PREF_KEY_FIRST_RUN)) {
          Common.setBooleanPref(mContext,Const.PREF_NAME,Const.PREF_KEY_HIDE_UPDATE_HINTS,false);
          Common.setBooleanPref(mContext,Const.PREF_NAME,Const.PREF_KEY_ADS,true);
          Common.setBooleanPref(mContext,Shell.PREF_NAME,Shell.PREF_LOG,true);
          Common.setBooleanPref(mContext,Const.PREF_NAME,Const.PREF_KEY_CHECK_UPDATES,true);
          mActivity.runOnUiThread(new Runnable(){
            @Override public void run(){
              showUsageWarning();
            }
          }
);
        }
      }
      mActivity.runOnUiThread(new Runnable(){
        @Override public void run(){
          try {
            setContentView(R.layout.activity_rashr);
            mToolbar=(Toolbar)findViewById(R.id.toolbar);
            setSupportActionBar(mToolbar);
            mNavigationDrawerFragment=(NavigationDrawerFragment)getSupportFragmentManager().findFragmentById(R.id.navigation_drawer);
            mNavigationDrawerFragment.setUp(R.id.navigation_drawer,(DrawerLayout)findViewById(R.id.RashrLayout));
            AdView ads=(AdView)findViewById(R.id.ads);
            if (ads != null) {
              if (Common.getBooleanPref(mContext,Const.PREF_NAME,Const.PREF_KEY_ADS)) {
                ads.loadAd(new AdRequest().addTestDevice("String_Node_Str"));
              }
            }
            if (getIntent().getAction().equals(Intent.ACTION_VIEW)) {
              if (getIntent().getData().toString().endsWith("String_Node_Str")) {
                File zip=new File(getIntent().getData().getPath());
                if (zip.exists())                 switchTo(ScriptManagerFragment.newInstance(mActivity,zip));
              }
 else {
                File img=new File(getIntent().getData().getPath());
                if (img.exists())                 switchTo(FlashAsFragment.newInstance(mActivity,img,true));
              }
            }
 else {
              onNavigationDrawerItemSelected(0);
            }
          }
 catch (          NullPointerException e) {
            setContentView(R.layout.err_layout);
            mActivity.addError(Const.RASHR_TAG,e,false);
            AppCompatTextView tv=(AppCompatTextView)findViewById(R.id.tvErr);
            try {
              tv.setText(R.string.failed_setup_layout);
            }
 catch (            RuntimeException ex) {
              mActivity.addError(Const.RASHR_TAG,e,true);
              ex.printStackTrace();
            }
          }
        }
      }
);
    }
  }
);
  StartThread.start();
}