Program: 80561
Project: 80561
Buggy source:
public synchronized void createNotification(){
  int filledConts=0;
  int maxButtons;
  boolean filledSecondRow=false;
  Context mContext=getApplicationContext();
  if (moreAppsPage == 1)   updatePrefs();
  RemoteViews customNotifView=new RemoteViews(taskPackage,contLayout);
  RemoteViews customNotifBigView=customNotifView;
  AppDrawer appDrawer=new AppDrawer(taskPackage);
  appDrawer.createRow(rowLayout,R.id.notifRow);
  appDrawer.setImageLayouts(imageButtonLayout,imageContLayout);
  appDrawer.setPrefs(prefs);
  appDrawer.setContext(mContext);
  if (taskList.size() < numOfApps) {
    maxButtons=taskList.size();
  }
 else {
    maxButtons=numOfApps;
  }
  if (taskList.size() <= numOfApps) {
    Tools.HangarLog("String_Node_Str");
    secondRow=false;
  }
  int iconCacheCount=(maxButtons * (secondRow ? 2 : 1));
  appDrawer.setCount(iconCacheCount,Settings.CACHED_NOTIFICATION_ICON_LIMIT,secondRow);
  ArrayList<TaskInfo> pageList;
  if (moreAppsPage == 1) {
    if (pinnedList == null) {
      Tools.HangarLog("String_Node_Str");
      pinnedList=Tools.buildPinnedList(mContext,db);
      pinnedCount=pinnedList.size();
    }
    pageList=new ArrayList<TaskInfo>(taskList);
    pageList=new Tools().getPinnedTasks(mContext,pinnedList,pageList,iconCacheCount,moreApps);
  }
 else {
    if (pinnedCount > iconCacheCount)     pinnedCount=iconCacheCount - 1;
    pageList=getPageTasks(moreAppsPage,iconCacheCount);
    if (pageList == null) {
      moreAppsPage=1;
      createNotification();
      return;
    }
    pageList=new Tools().getPinnedTasks(mContext,null,pageList,iconCacheCount,moreApps);
  }
  Tools.HangarLog("String_Node_Str" + taskList.size() + "String_Node_Str"+ pageList.size()+ "String_Node_Str"+ numOfApps+ "String_Node_Str"+ maxButtons+ "String_Node_Str"+ moreAppsPage);
  customNotifBigView.removeAllViews(R.id.notifContainer);
  notificationTasks=new ArrayList<String>();
  for (int i=0; i <= pageList.size(); i++) {
    boolean wrapItUp=false;
    if (i == pageList.size())     wrapItUp=true;
    if (filledConts == maxButtons || wrapItUp) {
      if (filledSecondRow) {
        filledSecondRow=false;
        customNotifBigView=customNotifView;
        customNotifBigView.addView(R.id.notifContainer,appDrawer.getRow());
        break;
      }
 else {
        customNotifView.addView(R.id.notifContainer,appDrawer.getRow());
        filledSecondRow=true;
        filledConts=0;
        appDrawer.createRow(rowLayout,R.id.notifRow);
        appDrawer.setImageLayouts(imageButtonLayout,imageContLayout);
      }
    }
    if (!wrapItUp) {
      if (appDrawer.newItem(pageList.get(i),itemLayout)) {
        appDrawer.addItem();
        notificationTasks.add(pageList.get(i).packageName);
        filledConts++;
      }
    }
  }
  if (filledSecondRow && secondRow) {
    Tools.HangarLog("String_Node_Str");
    customNotifBigView=customNotifView;
    customNotifBigView.addView(R.id.notifContainer,appDrawer.getRow());
  }
  int smallIcon=iconMap.get(Settings.STATUSBAR_ICON_WHITE_WARM);
  try {
    smallIcon=iconMap.get(mIcon);
  }
 catch (  NullPointerException e) {
    e.printStackTrace();
  }
  Notification notification=new Notification.Builder(WatchfulService.this).setContentTitle(getResources().getString(R.string.app_name)).setContentText(getResources().getString(R.string.app_name)).setSmallIcon(smallIcon).setContent(customNotifView).setOngoing(true).setPriority(setPriority).build();
  if (secondRow) {
    notification.bigContentView=customNotifBigView;
  }
  Tools.HangarLog("String_Node_Str" + isNotificationRunning);
  if (isNotificationRunning) {
    NotificationManager mNotificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(1337,notification);
  }
 else {
    startForeground(1337,notification);
  }
  if (moreAppsPage > 1) {
    notificationTasks=null;
    pinnedList=null;
  }
  isNotificationRunning=true;
}

Fixed version (ground truth):
public synchronized void createNotification(){
  int filledConts=0;
  int maxButtons;
  boolean filledSecondRow=false;
  Context mContext=getApplicationContext();
  if (moreAppsPage == 1)   updatePrefs();
  RemoteViews customNotifView=new RemoteViews(taskPackage,contLayout);
  RemoteViews customNotifBigView=customNotifView;
  AppDrawer appDrawer=new AppDrawer(taskPackage);
  appDrawer.createRow(rowLayout,R.id.notifRow);
  appDrawer.setImageLayouts(imageButtonLayout,imageContLayout);
  appDrawer.setPrefs(prefs);
  appDrawer.setContext(mContext);
  if (taskList.size() < numOfApps) {
    maxButtons=taskList.size();
  }
 else {
    maxButtons=numOfApps;
  }
  if (taskList.size() <= numOfApps) {
    Tools.HangarLog("String_Node_Str");
    secondRow=false;
  }
  int iconCacheCount=(maxButtons * (secondRow ? 2 : 1));
  appDrawer.setCount(iconCacheCount,Settings.CACHED_NOTIFICATION_ICON_LIMIT,secondRow);
  ArrayList<TaskInfo> pageList;
  if (moreAppsPage == 1) {
    if (pinnedList == null) {
      Tools.HangarLog("String_Node_Str");
      pinnedList=Tools.buildPinnedList(mContext,db);
      pinnedCount=pinnedList.size();
    }
    pageList=new ArrayList<TaskInfo>(taskList);
    pageList=new Tools().getPinnedTasks(mContext,pinnedList,pageList,iconCacheCount,moreApps);
  }
 else {
    if (pinnedCount > iconCacheCount)     pinnedCount=iconCacheCount - 1;
    pageList=getPageTasks(moreAppsPage,iconCacheCount);
    if (pageList == null) {
      moreAppsPage=1;
      createNotification();
      return;
    }
    pageList=new Tools().getPinnedTasks(mContext,null,pageList,iconCacheCount,moreApps);
    if (pageList.size() == 1) {
      moreAppsPage=1;
      return;
    }
  }
  Tools.HangarLog("String_Node_Str" + taskList.size() + "String_Node_Str"+ pageList.size()+ "String_Node_Str"+ numOfApps+ "String_Node_Str"+ maxButtons+ "String_Node_Str"+ moreAppsPage);
  customNotifBigView.removeAllViews(R.id.notifContainer);
  notificationTasks=new ArrayList<String>();
  for (int i=0; i <= pageList.size(); i++) {
    boolean wrapItUp=false;
    if (i == pageList.size())     wrapItUp=true;
    if (filledConts == maxButtons || wrapItUp) {
      if (filledSecondRow) {
        filledSecondRow=false;
        customNotifBigView=customNotifView;
        customNotifBigView.addView(R.id.notifContainer,appDrawer.getRow());
        break;
      }
 else {
        customNotifView.addView(R.id.notifContainer,appDrawer.getRow());
        filledSecondRow=true;
        filledConts=0;
        appDrawer.createRow(rowLayout,R.id.notifRow);
        appDrawer.setImageLayouts(imageButtonLayout,imageContLayout);
      }
    }
    if (!wrapItUp) {
      if (appDrawer.newItem(pageList.get(i),itemLayout)) {
        appDrawer.addItem();
        notificationTasks.add(pageList.get(i).packageName);
        filledConts++;
      }
    }
  }
  if (filledSecondRow && secondRow) {
    Tools.HangarLog("String_Node_Str");
    customNotifBigView=customNotifView;
    customNotifBigView.addView(R.id.notifContainer,appDrawer.getRow());
  }
  int smallIcon=iconMap.get(Settings.STATUSBAR_ICON_WHITE_WARM);
  try {
    smallIcon=iconMap.get(mIcon);
  }
 catch (  NullPointerException e) {
    e.printStackTrace();
  }
  Notification notification=new Notification.Builder(WatchfulService.this).setContentTitle(getResources().getString(R.string.app_name)).setContentText(getResources().getString(R.string.app_name)).setSmallIcon(smallIcon).setContent(customNotifView).setOngoing(true).setPriority(setPriority).build();
  if (secondRow) {
    notification.bigContentView=customNotifBigView;
  }
  Tools.HangarLog("String_Node_Str" + isNotificationRunning);
  if (isNotificationRunning) {
    NotificationManager mNotificationManager=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
    mNotificationManager.notify(1337,notification);
  }
 else {
    startForeground(1337,notification);
  }
  if (moreAppsPage > 1) {
    notificationTasks=null;
    pinnedList=null;
  }
  isNotificationRunning=true;
}