Re: PATCH: fix memory corruption

From: Hubert Figuiere (hfiguiere@teaser.fr)
Date: Tue Sep 09 2003 - 03:22:03 EDT

  • Next message: James H. Cloos Jr.: "Re: otf fonts"

    On Tue, 2003-09-09 at 04:01, Martin Sevior wrote:
    > On Tue, 2003-09-09 at 10:55, Marc Maurer wrote:
    > > The attached patch fixes the memory corruption issues described on the
    > > user mailinglist
    > > (http://www.abisource.com/mailinglists/abiword-user/2003/Sep/0023.html)
    > >
    > > Marc
    >
    > Goods like a good quick fix. Feel free to commit.
    >
    > Longer term we should make m_pszDecimal and m_pszDelim UT_Strings not
    > hardcoded arrays.

    And also, if you have a static array, use sizeof to know its size.

    That would be do:

    XML_Char m_pszDecimal[80];
    memset(m_pszDecimal, 0, sizeof(m_pszDecimal));

    instead of:

    XML_Char m_pszDecimal[80];
    memset(m_pszDecimal, 0, 80);

    That way if you grow (or worse, shrink) the buffer, you are safe.

    Of course, this break if you change it to an XML_Char* and allocate it
    dynamically....

    Hub

    -- 
    "<erno> hm. I've lost a machine.. literally _lost_. it responds to ping,
    it works completely, I just can't figure out where in my apartment it
    is." --  http://www.bash.org/?5273
    


    This archive was generated by hypermail 2.1.4 : Tue Sep 09 2003 - 03:35:23 EDT