Backport of:

From 0cf4fb2bf6e5054cf3030a922dfff92a4c7c2e98 Mon Sep 17 00:00:00 2001
From: Michael R Sweet <msweet@msweet.org>
Date: Mon, 13 Apr 2026 13:52:55 -0400
Subject: [PATCH] Fix blank line detection in rastertolabel (Issue #1545)

---
 CHANGES.md             |  1 +
 filter/rastertolabel.c | 12 +++++-------
 2 files changed, 6 insertions(+), 7 deletions(-)

#diff --git a/CHANGES.md b/CHANGES.md
#index 9b01a096d7..3f7917b1e3 100644
#--- a/CHANGES.md
#+++ b/CHANGES.md
#@@ -41,6 +41,7 @@ Changes in CUPS v2.4.17 (YYYY-MM-DD)
# - Fixed a recursion issue with encoding of nested collections (Issue #1539)
# - Fixed parsing of the `LimitRequestBody`, `MaxLogSize`, and `MaxRequestSize`
#   directives in "cupsd.conf" (Issue #1540)
#+- Fixed blank line detection in the `rastertolabel` filter (Issue #1545)
# 
# 
# Changes in CUPS v2.4.16 (2025-12-04)
--- a/filter/rastertolabel.c
+++ b/filter/rastertolabel.c
@@ -757,8 +757,7 @@ OutputLine(ppd_file_t         *ppd,	/* I
 	* See if the line is blank; if not, write it to the printer...
 	*/
 
-	if (Buffer[0] ||
-            memcmp(Buffer, Buffer + 1, header->cupsBytesPerLine - 1))
+	if (Buffer[0] || memcmp(Buffer, Buffer + 1, header->cupsBytesPerLine - 1))
 	{
           if (Feed)
 	  {
@@ -787,7 +786,7 @@ OutputLine(ppd_file_t         *ppd,	/* I
         break;
 
     case ZEBRA_EPL_PAGE :
-        if (Buffer[0] || memcmp(Buffer, Buffer + 1, header->cupsBytesPerLine))
+        if (Buffer[0] || memcmp(Buffer, Buffer + 1, header->cupsBytesPerLine - 1))
 	{
           printf("GW0,%d,%d,1\n", y, header->cupsBytesPerLine);
 	  for (i = header->cupsBytesPerLine, ptr = Buffer; i > 0; i --, ptr ++)
@@ -871,7 +870,7 @@ OutputLine(ppd_file_t         *ppd,	/* I
         break;
 
     case ZEBRA_CPCL :
-        if (Buffer[0] || memcmp(Buffer, Buffer + 1, header->cupsBytesPerLine))
+        if (Buffer[0] || memcmp(Buffer, Buffer + 1, header->cupsBytesPerLine - 1))
 	{
 	  printf("CG %u 1 0 %d ", header->cupsBytesPerLine, y);
           fwrite(Buffer, 1, header->cupsBytesPerLine, stdout);
@@ -881,8 +880,7 @@ OutputLine(ppd_file_t         *ppd,	/* I
 	break;
 
     case INTELLITECH_PCL :
-	if (Buffer[0] ||
-            memcmp(Buffer, Buffer + 1, header->cupsBytesPerLine - 1))
+	if (Buffer[0] || memcmp(Buffer, Buffer + 1, header->cupsBytesPerLine - 1))
         {
 	  if (Feed)
 	  {
