On Mon, 26 May 2008, I wrote:
http://lists.harbour-project.org/pipermail/harbour/2008-May/007330.html
,-
| I compiled contrib/gtwvg/tests/demowvg.prg on Win32/BCC
|
| From the main menu, when I select Modeless Dialogs | Dialog First
| and then click on the mouse on the "(x)Harbour" entry of the listbox
| on the right, I get the following CodeGuard error:
`-

I found the cause of the error.
In contrib/gtwvg/wvtutils.c HB_FUNC( WIN_SENDMESSAGE )
there is a code like:

   if( cText )
   {
      char * szText = HB_TCHAR_CONVFROM( cText );
      hb_storc( szText, 4 );
      HB_TCHAR_FREE( szText );
      HB_TCHAR_FREE( cText );
   }

But, if UNICODE is not defined, HB_TCHAR_CONVFROM() just return
cText, which is actually hb_parc( 4 ) since HB_TCHAR_CONVTO() also
return the passed parameter as is when UNICODE is not defined
(see include/hbwince.h).

When you pass hb_parc( 4 ) as a parameter to hb_storc( szText, 4 ),
the source is freed before it can be used.

A dirty fix would be:

   if( cText )
   {
      #ifdef UNICODE
         char * szText = HB_TCHAR_CONVFROM( cText );
         hb_storc( szText, 4 );
         HB_TCHAR_FREE( szText );
      #else
         char * szText = hb_strdup( cText );
         hb_storc( szText, 4 );
         hb_xfree( szText );
      #endif
      HB_TCHAR_FREE( cText );
   }

It is dirty since you are not suppose to know that the HB_TCHAR_*
macros are depentent on UNICODE. Other options is to always
duplicate szText and free it (but then it looks less optimize to me).


  Chen.
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to