Program: 163179
Project: 163179
Buggy source:
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  toolbar=(Toolbar)findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  toolbarDetail=(Toolbar)findViewById(R.id.toolbarDetail);
  String gistId=null;
  String gistUser=null;
  boolean containsUser=false;
  boolean isAuthUser=false;
  Account[] accounts=AccountManager.get(this).getAccountsByType(getString(R.string.account_type));
  if (accounts.length > 0) {
    if ((Intent.ACTION_SEND.equals(getIntent().getAction())) || (Intent.ACTION_VIEW.equals(getIntent().getAction()))) {
      Uri uri=getIntent().getData();
      if (uri == null && getIntent().getStringExtra(Intent.EXTRA_TEXT) != null) {
        try {
          uri=Uri.parse(getIntent().getStringExtra(Intent.EXTRA_TEXT));
        }
 catch (        Exception e) {
          e.printStackTrace();
        }
      }
      if (uri != null) {
        gistId=uri.getLastPathSegment();
        if (uri.getPathSegments().size() > 1) {
          containsUser=true;
          gistUser=uri.getPathSegments().get(0);
        }
      }
    }
    loadUserGists=true;
    if (gistUser != null && gistId != null && toolbarDetail != null) {
      loadUserGists=false;
      setTitle(getString(R.string.user_gists,gistUser));
      showGistsFragment(gistUser);
      showGistDetailFragment(gistId);
    }
 else     if (gistId != null) {
      Intent launcherIntent=GistDetailActivity.createLauncherIntent(this,gistId);
      startActivity(launcherIntent);
      finish();
    }
    for (    Account account : accounts) {
      if (account.name.equals(gistUser)) {
        isAuthUser=true;
        break;
      }
    }
    if (!containsUser || isAuthUser) {
      createDrawer();
    }
    if (accounts.length > 0) {
      selectAccount(accounts[0]);
    }
  }
 else {
    Intent intent=new Intent(MainActivity.this,LoginActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra(Intent.EXTRA_INTENT,getIntent());
    startActivity(intent);
    finish();
  }
}

Fixed version (ground truth):
@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  toolbar=(Toolbar)findViewById(R.id.toolbar);
  setSupportActionBar(toolbar);
  toolbarDetail=(Toolbar)findViewById(R.id.toolbarDetail);
  String gistId=null;
  String gistUser=null;
  boolean containsUser=false;
  boolean isAuthUser=false;
  Account[] accounts=AccountManager.get(this).getAccountsByType(getString(R.string.account_type));
  if (accounts.length > 0) {
    if ((Intent.ACTION_SEND.equals(getIntent().getAction())) || (Intent.ACTION_VIEW.equals(getIntent().getAction()))) {
      Uri uri=getIntent().getData();
      if (uri == null && getIntent().getStringExtra(Intent.EXTRA_TEXT) != null) {
        try {
          uri=Uri.parse(getIntent().getStringExtra(Intent.EXTRA_TEXT));
        }
 catch (        Exception e) {
          e.printStackTrace();
        }
      }
      if (uri != null) {
        gistId=uri.getLastPathSegment();
        if (uri.getPathSegments().size() > 1) {
          containsUser=true;
          gistUser=uri.getPathSegments().get(0);
        }
      }
    }
    loadUserGists=true;
    if (gistUser != null && gistId != null && toolbarDetail != null) {
      loadUserGists=false;
      setTitle(getString(R.string.user_gists,gistUser));
      showGistsFragment(gistUser);
      showGistDetailFragment(gistId);
    }
 else     if (gistId != null) {
      Intent launcherIntent=GistDetailActivity.createLauncherIntent(this,gistId);
      startActivity(launcherIntent);
      finish();
    }
    for (    Account account : accounts) {
      if (account.name.equals(gistUser)) {
        isAuthUser=true;
        break;
      }
    }
    if (!containsUser || isAuthUser) {
      createDrawer();
    }
  }
 else {
    Intent intent=new Intent(MainActivity.this,LoginActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra(Intent.EXTRA_INTENT,getIntent());
    startActivity(intent);
    finish();
  }
}