]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
Cast RGB values to unsigned before packing
authorRohit Kumar <149245736+rkt0209@users.noreply.github.com>
Wed, 4 Mar 2026 03:49:40 +0000 (09:19 +0530)
committerTill Kamppeter <till.kamppeter@gmail.com>
Thu, 5 Mar 2026 17:31:02 +0000 (18:31 +0100)
filter/rastertopclx.c

index 39cb378bf99fb32fe75729b2a58382f26f4a3b23..4a687dd9d89c40d0abc55cb65cd08a4b5860dbe1 100644 (file)
@@ -1377,8 +1377,8 @@ CompressData(unsigned char *line, // I - Data to compress
                // Pack 15-bit RGB difference...
                //
 
-               *comp_ptr++ = 0x80 | ((r << 2) & 0x7c) | ((g >> 3) & 0x03);
-               *comp_ptr++ = ((g << 5) & 0xe0) | (b & 0x1f);
+               *comp_ptr++ = 0x80 | (((unsigned)r << 2) & 0x7c) | ((g >> 3) & 0x03);
+*comp_ptr++ = (((unsigned)g << 5) & 0xe0) | (b & 0x1f);
              }
 
               count --;
@@ -1547,8 +1547,8 @@ CompressData(unsigned char *line, // I - Data to compress
                // Pack 15-bit RGB difference...
                //
 
-               *comp_ptr++ = 0x80 | ((r << 2) & 0x7c) | ((g >> 3) & 0x03);
-               *comp_ptr++ = ((g << 5) & 0xe0) | (b & 0x1f);
+               *comp_ptr++ = 0x80 | (((unsigned)r << 2) & 0x7c) | ((g >> 3) & 0x03);
+*comp_ptr++ = (((unsigned)g << 5) & 0xe0) | (b & 0x1f);
              }
 
               count --;