by Michael S. Kaplan, published on 2005/10/22 03:01 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2005/10/22/483573.aspx
It was just ages ago that I talked about Parameter Confusion in regard to the LCMapString function when used for sort keys, and Parameter Confusion in regard to GetLocaleInfo when numbers were returned.
Perhaps it just seems that way.
Of course I forgot about a case in that second post -- LOCALE_FONTSIGNATURE. This particular LCType has the following in the documentation:
Windows 95/98/Me, Windows NT 4.0 or later: A bit pattern used to determine the relationship between the character coverage needed to support the locale and the font contents. This information is returned in a LOCALESIGNATURE structure.
I am particularly proud of that bit in red, since it was added based on a bug I reported. :-)
Anyway, if you look at the structures you will see that a LOCALESIGNATURE sorta technically contains a FONTSIGNATURE:
typedef struct tagFONTSIGNATURE
} FONTSIGNATURE, *PFONTSIGNATURE,FAR *LPFONTSIGNATURE;
typedef struct tagLOCALESIGNATURE
} LOCALESIGNATURE, *PLOCALESIGNATURE,FAR *LPLOCALESIGNATURE;
Of course you see the problem in passing something the size of a FONTSIGNATURE and claiming it is the size of a LOCALESIGNATURE to make GetLocaleInfo happy, since it would inspire a small buffer overrun in the user code.
Which would kind of suck, obviously.
I personally reviewed one developer's work who had done just that in their code, which is one of the reasons I pushed for a doc change. :-)
Now, following the principles of that second Parameter Confusion post, cchDest is still expecting a count of characters, which means that the size of pass here is sizeof(LOCALESIGNATURE) / sizeof(TCHAR) and what to pass in the buffer is a LOCALESIGNATURE cast to a string so that the C compiler will not be unhappy with the parameter change.
Just a little more parameter confusion for an early Saturday morning....
This post brought to you by "ޟ" (U+079f, a.k.a. THAANA LETTER DAADHU)
# CornedBee on 22 Oct 2005 8:30 AM:
# Michael S. Kaplan on 22 Oct 2005 1:30 PM:
2006/02/08 They make 'em smarter than GetDateFormat
2005/12/19 It isn't a FONTSIGNATURE, darn it!
go to newer or older post, or back to index or month or day