php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30573 Compiler Warning Due to Invalid Incorrect Type Cast
Submitted: 2004-10-27 04:10 UTC Modified: 2005-02-21 11:15 UTC
From: jbarwick at sentienthealth dot com Assigned: moriyoshi (profile)
Status: Closed Package: Compile Warning
PHP Version: 4.3.8 OS: SuSE9.1 (amd64)
Private report: No CVE-ID: None
 [2004-10-27 04:10 UTC] jbarwick at sentienthealth dot com
Description:
------------
file in consideration:

ext/mbstring/libmbfl/filters/mbfilter_htmlent.c  line 156

The line in question is written as:

filter->cache = (int)mbfl_malloc(html_enc_buffer_size+1);

This line is invalid on 64 bit systems as mbfl_malloc should be returning a pointer (64 bit) and int is not...

filter->cache is defined as a long ... questions, should it be ulong?  don't wanna change it cuz I don't know if there is any negative math used here....

Anyway, if we rewrite the line to:

filter->cache = (long)mbfl_malloc(html_enc_buffer_size+1);

we fix the invalid data type size, and this WILL work on both 32 bit and 64 bit systems.

Throwing away the top 32 bits of a 64 bit pointer is extremely dangerous...don't you think?

Reproduce code:
---------------
compile the source

Expected result:
----------------
no compiler warnings

Actual result:
--------------
compiler warnings:
cast from pointer ot integer of different size..

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-21 11:15 UTC] moriyoshi@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 11:01:30 2024 UTC