summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorMartin Kraemer <martin@php.net>2004-01-28 16:25:12 +0000
committerMartin Kraemer <martin@php.net>2004-01-28 16:25:12 +0000
commit01c6257c5c8d6d0473271c006392b5d43f1214e9 (patch)
treefd3388138b37c6930b02e12fddebde17f1fa0e0b /ext
parent381d4e4ffa1e771e6294b42f48706b3dd8e12b78 (diff)
downloadphp-git-01c6257c5c8d6d0473271c006392b5d43f1214e9.tar.gz
Bug fix: Images would be broken on big-endian machines because the putc
function wrote the first (instead of "the low order") byte. That resulted in unexpected zero bytes.
Diffstat (limited to 'ext')
-rw-r--r--ext/gd/gd_ctx.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/gd/gd_ctx.c b/ext/gd/gd_ctx.c
index d1ec8e0c25..6fb7b84ce4 100644
--- a/ext/gd/gd_ctx.c
+++ b/ext/gd/gd_ctx.c
@@ -24,8 +24,13 @@
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)