Hi Roberto,

Compiled fine, but application GPFs at the following function:

----------------------------------------------------------------
HB_FUNC ( ADDLISTVIEWITEMS )
{

        char *caption;

This should be declared 'const'.

        LV_ITEM LI;
        HWND h;
        int l;
        int s;
        int c;

        h = (HWND) hb_parnl( 1 ) ;

Here, it's best to use hb_parnint() for 64-bit compatibility
(or even hb_parptr(), but that will break API compatibility).

        l = hb_parinfa( 2, 0 ) - 1 ;

        c = ListView_GetItemCount (h);
        caption [0] = 0 ;

Above line assigns 0 to a non-allocated memory area. It
can cause a GPF. It's not necessary anyway, so it should
be simply deleted.

        caption = hb_parvc ( 2 , 1 ); // <------------ CHANGED

        LI.mask=LVIF_TEXT | LVIF_IMAGE ;        
        LI.state=0;
        LI.stateMask=0;
       LI.iImage=hb_parni( 3 ); 
       LI.iSubItem=0;
        LI.iItem=c;
        LI.pszText=caption;

Here, probably a copy of the original buffer should be
stored in LI.pszText. It's declared as non-const, so
it's possible that Windows will touch the buffer content.

        ListView_InsertItem(h,&LI);

        for (s = 1 ; s<=l ; s=s+1 )
        {
                caption = hb_parvc ( 2 , s + 1 ); // <---------- CHANGED
                ListView_SetItemText(h,c,s,caption);

This looks safe since const string is expected, although
'caption' variable can be optimized out completely.

[ Both above hb_parvc() usage works for non-UNICODE builds only. ]

Brgds,
Viktor

_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to