Print Page | Close Window

Memory bug in XTPMarkupStatic

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=24646
Printed Date: 15 June 2026 at 7:15pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Memory bug in XTPMarkupStatic
Posted By: DavidH
Subject: Memory bug in XTPMarkupStatic
Date Posted: 15 June 2026 at 4:08pm
In Source/Controls/Static/XTPMarkupStatic.cpp, a growing buffer is not reallocated correctly.

template<class T>
AFX_INLINE BOOL XTPStrPushChr(T*& pStr, T ch, SIZE_T& nPos, SIZE_T& nSize)
{
    if (NULL == pStr)
    {
        nSize = 0x100;
        pStr  = (T*)malloc(nSize * sizeof(T));
        if (NULL == pStr)
            return FALSE;

        *pStr = T('\0');
        nPos  = 0;
    }

    pStr[nPos] = ch;
    if (++nPos == nSize)
    {
        nSize *= 2;
   // --->>>>     pStr = (T*)realloc(pStr, nSize);
   // Should be:
        pStr = (T*)realloc(pStr, nSize * sizeof(T));
        if (NULL == pStr)
            return FALSE;

        pStr[nPos] = T('\0');
    }

    return TRUE;
}



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net