From: Georg Richter Date: Tue, 14 Mar 2006 15:53:16 +0000 (+0000) Subject: fixed a 64-bit problem reported by Pierre X-Git-Tag: php-5.1.3RC2~110 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=829642a0b733a57b83f25ef99a9fa6893877599d;p=php fixed a 64-bit problem reported by Pierre --- diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index eec7a67b85..5bd1953528 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -295,7 +295,7 @@ PHP_FUNCTION(mysqli_stmt_bind_result) convert_to_long_ex(args[i]); stmt->result.buf[ofs].type = IS_LONG; stmt->result.buf[ofs].buflen = 0; - stmt->result.buf[ofs].val = (char *)emalloc(sizeof(long)); + stmt->result.buf[ofs].val = (char *)emalloc(sizeof(int)); bind[ofs].buffer_type = MYSQL_TYPE_LONG; bind[ofs].buffer = stmt->result.buf[ofs].val; bind[ofs].is_null = &stmt->result.is_null[ofs]; @@ -663,7 +663,7 @@ PHP_FUNCTION(mysqli_stmt_fetch) if (!stmt->result.is_null[i]) { switch (stmt->result.buf[i].type) { case IS_LONG: - if ((sizeof(long) ==4) && (stmt->stmt->fields[i].type == MYSQL_TYPE_LONG) + if ((stmt->stmt->fields[i].type == MYSQL_TYPE_LONG) && (stmt->stmt->fields[i].flags & UNSIGNED_FLAG)) { /* unsigned int (11) */ @@ -684,7 +684,11 @@ PHP_FUNCTION(mysqli_stmt_fetch) break; } } - ZVAL_LONG(stmt->result.vars[i], *(int *)stmt->result.buf[i].val); + if (stmt->stmt->fields[i].flags & UNSIGNED_FLAG) { + ZVAL_LONG(stmt->result.vars[i], *(unsigned int *)stmt->result.buf[i].val); + } else { + ZVAL_LONG(stmt->result.vars[i], *(int *)stmt->result.buf[i].val); + }; break; case IS_DOUBLE: memcpy(&dval, stmt->result.buf[i].val, sizeof(dval));