Program: 13695
Project: 13695
Buggy source:
@Override public void onActivityResult(int requestCode,int resultCode,Intent data){
  super.onActivityResult(requestCode,resultCode,data);
  if (requestCode == EDITOR_MEDIA_SETTINGS) {
    if (mTappedMediaPredicate != null) {
      if (data == null || data.getExtras() == null) {
        return;
      }
      EditorImageMetaData metaData=data.getParcelableExtra(ARG_EDITOR_IMAGE_METADATA);
      if (metaData.isRemoved()) {
        String editorContentBeforeImageIsRemoved="String_Node_Str";
        if (isHistoryEnabled()) {
          editorContentBeforeImageIsRemoved=content.toFormattedHtml();
        }
        content.removeMedia(mTappedMediaPredicate);
        if (isHistoryEnabled()) {
          content.history.beforeTextChanged(editorContentBeforeImageIsRemoved);
        }
      }
 else {
        if (isHistoryEnabled()) {
          content.history.beforeTextChanged(content.toFormattedHtml());
        }
        AztecAttributes attributes=content.getElementAttributes(mTappedMediaPredicate);
        attributes.setValue(ATTR_SRC,metaData.getSrc());
        if (!TextUtils.isEmpty(metaData.getTitle())) {
          attributes.setValue(ATTR_TITLE,metaData.getTitle());
        }
 else {
          attributes.removeAttribute(ATTR_TITLE);
        }
        if (!TextUtils.isEmpty(metaData.getAlt())) {
          attributes.setValue(ATTR_ALT,metaData.getAlt());
        }
 else {
          attributes.removeAttribute(ATTR_ALT);
        }
        attributes.setValue(ATTR_DIMEN_WIDTH,metaData.getWidth());
        attributes.setValue(ATTR_DIMEN_HEIGHT,metaData.getHeight());
        if (!TextUtils.isEmpty(metaData.getLinkUrl())) {
          String existingLink=MediaLinkExtensionsKt.getMediaLink(content,mTappedMediaPredicate);
          if (TextUtils.isEmpty(existingLink)) {
            AztecAttributes linkAttributes=new AztecAttributes();
            if (metaData.isLinkTargetBlank()) {
              linkAttributes.setValue(ATTR_TARGET,"String_Node_Str");
            }
            MediaLinkExtensionsKt.addLinkToMedia(content,mTappedMediaPredicate,metaData.getLinkUrl(),linkAttributes);
          }
 else {
            AztecAttributes linkAttributes=MediaLinkExtensionsKt.getMediaLinkAttributes(content,mTappedMediaPredicate);
            if (metaData.isLinkTargetBlank()) {
              linkAttributes.setValue(ATTR_TARGET,"String_Node_Str");
            }
 else {
              linkAttributes.removeAttribute(ATTR_TARGET);
            }
            MediaLinkExtensionsKt.addLinkToMedia(content,mTappedMediaPredicate,metaData.getLinkUrl(),linkAttributes);
          }
        }
 else {
          MediaLinkExtensionsKt.removeLinkFromMedia(content,mTappedMediaPredicate);
        }
        AttributesWithClass attributesWithClass=getAttributesWithClass(attributes);
        attributesWithClass.removeClassStartingWith(ATTR_ALIGN);
        attributesWithClass.removeClassStartingWith(ATTR_SIZE_DASH);
        attributesWithClass.removeClassStartingWith(ATTR_IMAGE_WP_DASH);
        if (!TextUtils.isEmpty(metaData.getCaption())) {
          AztecAttributes captionAttributes=CaptionExtensionsKt.getImageCaptionAttributes(content,mTappedMediaPredicate);
          if (!TextUtils.isEmpty(metaData.getAlign())) {
            captionAttributes.setValue(ATTR_ALIGN,ATTR_ALIGN + metaData.getAlign());
          }
 else {
            captionAttributes.removeAttribute(ATTR_ALIGN);
          }
          captionAttributes.setValue(ATTR_DIMEN_WIDTH,metaData.getWidth());
          CaptionExtensionsKt.setImageCaption(content,mTappedMediaPredicate,metaData.getCaption(),captionAttributes);
        }
 else {
          if (!TextUtils.isEmpty(metaData.getAlign())) {
            attributesWithClass.addClass(ATTR_ALIGN + metaData.getAlign());
          }
          CaptionExtensionsKt.removeImageCaption(content,mTappedMediaPredicate);
        }
        if (!TextUtils.isEmpty(metaData.getSize())) {
          attributesWithClass.addClass(metaData.getSize());
        }
        if (!TextUtils.isEmpty(metaData.getAttachmentId())) {
          attributesWithClass.addClass(ATTR_IMAGE_WP_DASH + metaData.getAttachmentId());
        }
        attributes.setValue(ATTR_CLASS,attributesWithClass.getAttributes().getValue(ATTR_CLASS));
        attributes.removeAttribute(TEMP_IMAGE_ID);
        content.updateElementAttributes(mTappedMediaPredicate,attributes);
      }
      mTappedMediaPredicate=null;
      if (isHistoryEnabled()) {
        content.history.handleHistory(content);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onActivityResult(int requestCode,int resultCode,Intent data){
  super.onActivityResult(requestCode,resultCode,data);
  if (requestCode == EDITOR_MEDIA_SETTINGS) {
    if (mTappedMediaPredicate != null) {
      if (data == null || data.getExtras() == null) {
        return;
      }
      EditorImageMetaData metaData=data.getParcelableExtra(ARG_EDITOR_IMAGE_METADATA);
      if (metaData.isRemoved()) {
        String editorContentBeforeImageIsRemoved="String_Node_Str";
        if (isHistoryEnabled()) {
          editorContentBeforeImageIsRemoved=content.toFormattedHtml();
        }
        content.removeMedia(mTappedMediaPredicate);
        if (isHistoryEnabled()) {
          content.history.beforeTextChanged(editorContentBeforeImageIsRemoved);
        }
      }
 else {
        if (isHistoryEnabled()) {
          content.history.beforeTextChanged(content.toFormattedHtml());
        }
        AztecAttributes attributes=content.getElementAttributes(mTappedMediaPredicate);
        attributes.setValue(ATTR_SRC,metaData.getSrc());
        if (!TextUtils.isEmpty(metaData.getTitle())) {
          attributes.setValue(ATTR_TITLE,metaData.getTitle());
        }
 else {
          attributes.removeAttribute(ATTR_TITLE);
        }
        if (!TextUtils.isEmpty(metaData.getAlt())) {
          attributes.setValue(ATTR_ALT,metaData.getAlt());
        }
 else {
          attributes.removeAttribute(ATTR_ALT);
        }
        attributes.setValue(ATTR_DIMEN_WIDTH,metaData.getWidth());
        attributes.setValue(ATTR_DIMEN_HEIGHT,metaData.getHeight());
        if (!TextUtils.isEmpty(metaData.getLinkUrl())) {
          String existingLink=MediaLinkExtensionsKt.getMediaLink(content,mTappedMediaPredicate);
          AztecAttributes linkAttributes;
          if (TextUtils.isEmpty(existingLink)) {
            linkAttributes=new AztecAttributes();
          }
 else {
            linkAttributes=MediaLinkExtensionsKt.getMediaLinkAttributes(content,mTappedMediaPredicate);
          }
          linkAttributes.setValue("String_Node_Str","String_Node_Str");
          if (metaData.isLinkTargetBlank()) {
            linkAttributes.setValue(ATTR_TARGET,"String_Node_Str");
          }
 else {
            linkAttributes.removeAttribute(ATTR_TARGET);
          }
          MediaLinkExtensionsKt.removeLinkFromMedia(content,mTappedMediaPredicate);
          MediaLinkExtensionsKt.addLinkToMedia(content,mTappedMediaPredicate,UrlUtils.addUrlSchemeIfNeeded(metaData.getLinkUrl(),false),linkAttributes);
        }
 else {
          MediaLinkExtensionsKt.removeLinkFromMedia(content,mTappedMediaPredicate);
        }
        AttributesWithClass attributesWithClass=getAttributesWithClass(attributes);
        attributesWithClass.removeClassStartingWith(ATTR_ALIGN);
        attributesWithClass.removeClassStartingWith(ATTR_SIZE_DASH);
        attributesWithClass.removeClassStartingWith(ATTR_IMAGE_WP_DASH);
        if (!TextUtils.isEmpty(metaData.getCaption())) {
          AztecAttributes captionAttributes=CaptionExtensionsKt.getImageCaptionAttributes(content,mTappedMediaPredicate);
          if (!TextUtils.isEmpty(metaData.getAlign())) {
            captionAttributes.setValue(ATTR_ALIGN,ATTR_ALIGN + metaData.getAlign());
          }
 else {
            captionAttributes.removeAttribute(ATTR_ALIGN);
          }
          captionAttributes.setValue(ATTR_DIMEN_WIDTH,metaData.getWidth());
          CaptionExtensionsKt.setImageCaption(content,mTappedMediaPredicate,metaData.getCaption(),captionAttributes);
        }
 else {
          if (!TextUtils.isEmpty(metaData.getAlign())) {
            attributesWithClass.addClass(ATTR_ALIGN + metaData.getAlign());
          }
          CaptionExtensionsKt.removeImageCaption(content,mTappedMediaPredicate);
        }
        if (!TextUtils.isEmpty(metaData.getSize())) {
          attributesWithClass.addClass(metaData.getSize());
        }
        if (!TextUtils.isEmpty(metaData.getAttachmentId())) {
          attributesWithClass.addClass(ATTR_IMAGE_WP_DASH + metaData.getAttachmentId());
        }
        attributes.setValue(ATTR_CLASS,attributesWithClass.getAttributes().getValue(ATTR_CLASS));
        attributes.removeAttribute(TEMP_IMAGE_ID);
        content.updateElementAttributes(mTappedMediaPredicate,attributes);
      }
      mTappedMediaPredicate=null;
      if (isHistoryEnabled()) {
        content.history.handleHistory(content);
      }
    }
  }
}