Program: 22566
Project: 22566
Buggy source:
private void handleHeaders(Headers headers){
  if (mCancelled)   return;
  mHeaders=headers;
  long contentLength=headers.getContentLength();
  if (contentLength != Headers.NO_CONTENT_LENGTH) {
    mContentLength=contentLength;
  }
 else {
    mContentLength=0;
  }
  String contentType=headers.getContentType();
  if (contentType != null) {
    parseContentTypeHeader(contentType);
    if (mMimeType.equals("String_Node_Str") || mMimeType.equals("String_Node_Str")) {
      String contentDisposition=headers.getContentDisposition();
      String url=null;
      if (contentDisposition != null) {
        url=URLUtil.parseContentDisposition(contentDisposition);
      }
      if (url == null) {
        url=mUrl;
      }
      String newMimeType=guessMimeTypeFromExtension(url);
      if (newMimeType != null) {
        mMimeType=newMimeType;
      }
    }
 else     if (mMimeType.equals("String_Node_Str")) {
      mMimeType="String_Node_Str";
    }
 else {
      if (mMimeType.equals("String_Node_Str")) {
        mMimeType="String_Node_Str";
      }
    }
  }
 else {
    guessMimeType();
  }
  if (mIsMainPageLoader && mIsMainResourceLoader && mUserGesture&& Pattern.matches(XML_MIME_TYPE,mMimeType)) {
    Intent i=new Intent(Intent.ACTION_VIEW);
    i.setDataAndType(Uri.parse(url()),mMimeType);
    ResolveInfo info=mContext.getPackageManager().resolveActivity(i,PackageManager.MATCH_DEFAULT_ONLY);
    if (info != null && !mContext.getPackageName().equals(info.activityInfo.packageName)) {
      try {
        mContext.startActivity(i);
        mBrowserFrame.stopLoading();
        return;
      }
 catch (      ActivityNotFoundException ex) {
      }
    }
  }
  boolean mustAuthenticate=(mStatusCode == HTTP_AUTH || mStatusCode == HTTP_PROXY_AUTH);
  boolean isProxyAuthRequest=(mStatusCode == HTTP_PROXY_AUTH);
  mAuthFailed=false;
  if (mAuthHeader != null) {
    mAuthFailed=(mustAuthenticate && isProxyAuthRequest == mAuthHeader.isProxy());
    if (!mAuthFailed && mAuthHeader.isProxy()) {
      Network network=Network.getInstance(mContext);
      if (network.isValidProxySet()) {
synchronized (network) {
          network.setProxyUsername(mAuthHeader.getUsername());
          network.setProxyPassword(mAuthHeader.getPassword());
        }
      }
    }
  }
  mAuthHeader=null;
  if (mustAuthenticate) {
    if (mStatusCode == HTTP_AUTH) {
      mAuthHeader=parseAuthHeader(headers.getWwwAuthenticate());
    }
 else {
      mAuthHeader=parseAuthHeader(headers.getProxyAuthenticate());
      if (mAuthHeader != null) {
        mAuthHeader.setProxy();
      }
    }
  }
  if ((mStatusCode == HTTP_OK || mStatusCode == HTTP_FOUND || mStatusCode == HTTP_MOVED_PERMANENTLY || mStatusCode == HTTP_TEMPORARY_REDIRECT) && mNativeLoader != 0) {
    if (!mFromCache && mRequestHandle != null && (!mRequestHandle.getMethod().equals("String_Node_Str") || mPostIdentifier != 0)) {
      WebViewWorker.CacheCreateData data=new WebViewWorker.CacheCreateData();
      data.mListener=this;
      data.mUrl=mUrl;
      data.mMimeType=mMimeType;
      data.mStatusCode=mStatusCode;
      data.mPostId=mPostIdentifier;
      data.mHeaders=headers;
      WebViewWorker.getHandler().obtainMessage(WebViewWorker.MSG_CREATE_CACHE,data).sendToTarget();
    }
    WebViewWorker.CacheEncoding ce=new WebViewWorker.CacheEncoding();
    WebViewWorker.getHandler().obtainMessage(WebViewWorker.MSG_UPDATE_CACHE_ENCODING,ce).sendToTarget();
  }
  commitHeadersCheckRedirect();
}

Fixed version (ground truth):
private void handleHeaders(Headers headers){
  if (mCancelled)   return;
  mHeaders=headers;
  long contentLength=headers.getContentLength();
  if (contentLength != Headers.NO_CONTENT_LENGTH) {
    mContentLength=contentLength;
  }
 else {
    mContentLength=0;
  }
  String contentType=headers.getContentType();
  if (contentType != null) {
    parseContentTypeHeader(contentType);
    if (mMimeType.equals("String_Node_Str") || mMimeType.equals("String_Node_Str")) {
      String contentDisposition=headers.getContentDisposition();
      String url=null;
      if (contentDisposition != null) {
        url=URLUtil.parseContentDisposition(contentDisposition);
      }
      if (url == null) {
        url=mUrl;
      }
      String newMimeType=guessMimeTypeFromExtension(url);
      if (newMimeType != null) {
        mMimeType=newMimeType;
      }
    }
 else     if (mMimeType.equals("String_Node_Str")) {
      mMimeType="String_Node_Str";
    }
 else {
      if (mMimeType.equals("String_Node_Str")) {
        mMimeType="String_Node_Str";
      }
    }
  }
 else {
    guessMimeType();
  }
  if (mIsMainPageLoader && mIsMainResourceLoader && mUserGesture&& Pattern.matches(XML_MIME_TYPE,mMimeType)) {
    Intent i=new Intent(Intent.ACTION_VIEW);
    i.setDataAndType(Uri.parse(url()),mMimeType);
    ResolveInfo info=mContext.getPackageManager().resolveActivity(i,PackageManager.MATCH_DEFAULT_ONLY);
    if (info != null && !mContext.getPackageName().equals(info.activityInfo.packageName)) {
      try {
        mContext.startActivity(i);
        mBrowserFrame.stopLoading();
        return;
      }
 catch (      ActivityNotFoundException ex) {
      }
    }
  }
  boolean mustAuthenticate=(mStatusCode == HTTP_AUTH || mStatusCode == HTTP_PROXY_AUTH);
  boolean isProxyAuthRequest=(mStatusCode == HTTP_PROXY_AUTH);
  mAuthFailed=false;
  if (mAuthHeader != null) {
    mAuthFailed=(mustAuthenticate && isProxyAuthRequest == mAuthHeader.isProxy());
    if (!mAuthFailed && mAuthHeader.isProxy()) {
      Network network=Network.getInstance(mContext);
      if (network.isValidProxySet()) {
synchronized (network) {
          network.setProxyUsername(mAuthHeader.getUsername());
          network.setProxyPassword(mAuthHeader.getPassword());
        }
      }
    }
  }
  mAuthHeader=null;
  if (mustAuthenticate) {
    if (mStatusCode == HTTP_AUTH) {
      mAuthHeader=parseAuthHeader(headers.getWwwAuthenticate());
    }
 else {
      mAuthHeader=parseAuthHeader(headers.getProxyAuthenticate());
      if (mAuthHeader != null) {
        mAuthHeader.setProxy();
      }
    }
  }
  if ((mStatusCode == HTTP_OK || mStatusCode == HTTP_FOUND || mStatusCode == HTTP_MOVED_PERMANENTLY || mStatusCode == HTTP_TEMPORARY_REDIRECT) && mNativeLoader != 0) {
    if (!mFromCache && mRequestHandle != null && (!mRequestHandle.getMethod().equals("String_Node_Str") || mPostIdentifier != 0)) {
      WebViewWorker.CacheCreateData data=new WebViewWorker.CacheCreateData();
      data.mListener=this;
      data.mUrl=mUrl;
      data.mMimeType=mMimeType;
      data.mStatusCode=mStatusCode;
      data.mPostId=mPostIdentifier;
      data.mHeaders=headers;
      WebViewWorker.getHandler().obtainMessage(WebViewWorker.MSG_CREATE_CACHE,data).sendToTarget();
    }
    WebViewWorker.CacheEncoding ce=new WebViewWorker.CacheEncoding();
    ce.mEncoding=mEncoding;
    WebViewWorker.getHandler().obtainMessage(WebViewWorker.MSG_UPDATE_CACHE_ENCODING,ce).sendToTarget();
  }
  commitHeadersCheckRedirect();
}