]> granicus.if.org Git - php/commitdiff
Bug fix: Images would be broken on big-endian machines because the putc
authorMartin Kraemer <martin@php.net>
Wed, 28 Jan 2004 16:25:12 +0000 (16:25 +0000)
committerMartin Kraemer <martin@php.net>
Wed, 28 Jan 2004 16:25:12 +0000 (16:25 +0000)
function wrote the first (instead of "the low order") byte. That resulted
in unexpected zero bytes.

ext/gd/gd_ctx.c

index d1ec8e0c25cc4fe3852bcee1c16192eb87122f5b..6fb7b84ce4d7c1422cdb46b3022175e40596bc32 100644 (file)
 
 static void _php_image_output_putc(struct gdIOCtx *ctx, int c)
 {
+       /* without the following downcast, the write will fail
+        * (i.e., will write a zero byte) for all
+        * big endian architectures:
+        */
+       unsigned char ch = (unsigned char) c;
        TSRMLS_FETCH();
-       php_write(&c, 1 TSRMLS_CC);
+       php_write(&ch, 1 TSRMLS_CC);
 }
 
 static int _php_image_output_putbuf(struct gdIOCtx *ctx, const void* buf, int l)