FIX: AfxIsValidString() Returns TRUE for NULL Near PointersLast reviewed: September 18, 1997Article ID: Q113535 |
1.00
WINDOWS
kbprg kbfixlist kbbuglist
The information in this article applies to:
SYMPTOMSCalling AfxIsValidString() with a near NULL pointer results in a TRUE return value. The return value should be FALSE because a NULL pointer is invalid. For example, consider the following code:
char NEAR * npszEmpty = NULL; ASSERT(AfxIsValidString(npszEmpty));This should cause the assertion to fail but doesn't.
CAUSEAfxIsValidString() takes an LPCSTR, which is defined in WINDOWS.H as:
typedef const char FAR* LPCSTR; // far pointer to a read-only stringTherefore, the "char NEAR *" parameter is first converted to a LPCSTR or FAR pointer, which changes it from an offset-only value of 0x0000 to a selector:offset value of DS:0x0000. This value will not evaluate to NULL because the data segment register will most likely contain a nonzero value.
RESOLUTIONTo work around this problem, do one of the following:
STATUSMicrosoft has confirmed this to be a problem in the Microsoft Foundation Classes version 2.0. This problem was corrected in the Microsoft Foundation Classes version 2.5.
|
Additional reference words: 1.00 2.00 return valid pointer
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |