Re: kernel32: Don't crash accessing an invalid handle in GlobalSize [try3]
"James Hawkins" <truiken(a)gmail.com> wrote:
This version compares the pointer value to 64000 instead of using a try/catch block, as suggested by Alexandre.
- if(pintern->Magic==MAGIC_GLOBAL_USED) + if(pintern > (PGLOBAL32_INTERN)64000 && pintern->Magic==MAGIC_GLOBAL_USED) { if (!pintern->Pointer) /* handle case of GlobalAlloc( ??,0) */
It should be either 65535 (0xffff), or a test for HIWORD(pintern) being 0. Also the cast should be to (char *) on both sides rather than (PGLOBAL32_INTERN). -- Dmitry.
On 9/20/07, Dmitry Timoshkov <dmitry(a)codeweavers.com> wrote:
"James Hawkins" <truiken(a)gmail.com> wrote:
This version compares the pointer value to 64000 instead of using a try/catch block, as suggested by Alexandre.
- if(pintern->Magic==MAGIC_GLOBAL_USED) + if(pintern > (PGLOBAL32_INTERN)64000 && pintern->Magic==MAGIC_GLOBAL_USED) { if (!pintern->Pointer) /* handle case of GlobalAlloc( ??,0) */
It should be either 65535 (0xffff), or a test for HIWORD(pintern) being 0. Also the cast should be to (char *) on both sides rather than (PGLOBAL32_INTERN).
I'll go with HIWORD(pintern), thanks for the suggestion. I knew it wasn't quite right :) -- James Hawkins
participants (2)
-
Dmitry Timoshkov -
James Hawkins