Compiler Warning Due to Invalid Incorrect Type Cast
| 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 commits
[2005-02-21 11:15 UTC] moriyoshi@php.net