Ignore:
Timestamp:
Mar 3, 2003, 5:33:35 PM (22 years ago)
Author:
sandervl
Message:

DT: ExtTextOutA: copy string and force zero termination

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gdi32/text.cpp

    r9737 r9886  
    1 /* $Id: text.cpp,v 1.32 2003-01-28 16:21:49 sandervl Exp $ */
     1/* $Id: text.cpp,v 1.33 2003-03-03 16:33:35 sandervl Exp $ */
    22
    33/*
     
    298298BOOL WIN32API ExtTextOutA(HDC hdc,int X,int Y,UINT fuOptions,CONST RECT *lprc,LPCSTR lpszString,UINT cbCount,CONST INT *lpDx)
    299299{
    300   if(lprc) {
    301         dprintf(("GDI32: ExtTextOutA %x %s (%d,%d) %x %d %x rect (%d,%d)(%d,%d)", hdc, lpszString, X, Y, fuOptions, cbCount, lpDx, lprc->left, lprc->top, lprc->right, lprc->bottom));
    302   }
    303   else  dprintf(("GDI32: ExtTextOutA %x %s (%d,%d) %x %d %x", hdc, lpszString, X, Y, fuOptions, cbCount, lpDx));
    304 
    305   return InternalTextOutA(hdc, X, Y, fuOptions, lprc, lpszString, cbCount, lpDx, TRUE);
     300  LPSTR astring = NULL;
     301  LPCSTR aCstring = lpszString;
     302  BOOL  rc;
     303
     304  /* no guarantee for zeroterminated text in lpszString, found in "PuTTY A Free Win32 Telnet SSH Client" */
     305  if (cbCount >= 0)
     306  {
     307     astring = (char *)malloc(cbCount+1);
     308     memcpy(astring, lpszString, cbCount);
     309     astring[cbCount] = '\0';
     310     aCstring = astring;
     311  }
     312  if(lprc)
     313  {
     314        dprintf(("GDI32: ExtTextOutA %x %s (%d,%d) %x %d %x rect (%d,%d)(%d,%d)", hdc, /*lpszString*/ aCstring, X, Y, fuOptions, cbCount, lpDx, lprc->left, lprc->top, lprc->right, lprc->bottom));
     315  }
     316  else  dprintf(("GDI32: ExtTextOutA %x %s (%d,%d) %x %d %x", hdc, /*lpszString*/ aCstring, X, Y, fuOptions, cbCount, lpDx));
     317
     318  rc = InternalTextOutA(hdc, X, Y, fuOptions, lprc, aCstring, cbCount, lpDx, TRUE);
     319
     320  if(astring)
     321      free(astring);
     322 
     323  return(rc);
    306324}
    307325//******************************************************************************
     
    382400   if(cbString == 0)
    383401   {
    384       dprintf(("GDI32: GetTextExtentPointW cbString == 0"));
     402      dprintf(("GDI32: GetTextExtentPointA cbString == 0"));
    385403      SetLastError(ERROR_SUCCESS);
    386404      return TRUE;
Note: See TracChangeset for help on using the changeset viewer.