BUG: GetKerningPairs Sometimes Fails on Win32s 1.2 and 1.25a (125872)



The information in this article applies to:

  • Microsoft Win32 Application Programming Interface (API), when used with:
    • Microsoft Win32s 1.25

This article was previously published under Q125872
1.20 1.25a WINDOWS kbgraphic kbbuglist

SYMPTOMS

GetKerningPairs will sometimes fail on Win32s version 1.2 causing the 32-bit application to exit mysteriously. The problem may only occur once in a while with many successful runs interrupted by a single unsuccessful run.

CAUSE

The thunking layer for GetKerningPairs contains a bug in the code that allocates a temporary buffer passed to the 16-bit version of GetKerningPairs. The errant code executes whenever the number of kerning pairs requested is equal to or less than 128. Requesting GetKerningPairs to return 129 or more kerning pairs forces the thunking layer to use an alternative buffer allocation method.

RESOLUTION

To work around the problem, ensure that the number of kerning pairs requested from GetKerningPairs is greater than 128.

Typically, kerning pairs are retrieved with two calls to GetKerningPairs. The first call retrieves the number of kerning pairs available. A buffer is allocated based on the number of pairs returned. Then the second call to GetKerningPairs retrieves the kerning pairs into the buffer.

To avoid the bug in GetKerningPairs, follow these steps:
  1. Retrieve the number of kerning pairs available from GetKerningPairs.
  2. Check that this value is greater than 128. If it is less than or equal to 128, reset the variable to an arbitrary value greater than 128 -- like 129.
  3. Use the new value to allocate the buffer of KERNINGPAIRS and pass this new value with the buffer to the second GetKerningPairs call.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

Modification Type:MinorLast Reviewed:3/7/2005
Keywords:kbbug kbpending KB125872