diff --git a/share/html/Ticket/Attachment/dhandler b/share/html/Ticket/Attachment/dhandler
index 442c63193eb..045896aaed8 100644
--- a/share/html/Ticket/Attachment/dhandler
+++ b/share/html/Ticket/Attachment/dhandler
@@ -83,6 +83,7 @@ elsif (lc $content_type eq 'text/html') {
Content => \$content,
Attachment => $AttachmentObj,
);
+ $count //= 0; # RewriteInlineImages can return undef when nothing needs to be rewritten
RT->Logger->debug("Rewrote $count CID images when displaying original HTML attachment #$attach");
}