From 39f41aa607a84a42c483a6356f06ff9d54c1450c Mon Sep 17 00:00:00 2001 From: leo Date: Tue, 20 Jan 2009 02:07:33 +0000 Subject: Fixed HTML export crash, avoid more 0-size allocations. git-svn-id: http://svn.leocad.org/tags/leocad-0.75@732 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- common/minifig.cpp | 6 +++--- common/object.cpp | 5 +++++ common/pieceinf.cpp | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/minifig.cpp b/common/minifig.cpp index 9098e49..805b066 100644 --- a/common/minifig.cpp +++ b/common/minifig.cpp @@ -458,8 +458,8 @@ MinifigWizard::MinifigWizard (GLWindow *share) char *ptr, buf[32]; m_MinifigCount = Sys_ProfileLoadInt ("MinifigWizard", "Count", 0); - m_MinifigNames = (char**)realloc (m_MinifigNames, sizeof (char**)*m_MinifigCount); - m_MinifigTemplates = (char**)realloc (m_MinifigTemplates, sizeof (char**)*m_MinifigCount); + m_MinifigNames = (char**)realloc(m_MinifigNames, sizeof(char**) * (m_MinifigCount+1)); + m_MinifigTemplates = (char**)realloc(m_MinifigTemplates, sizeof(char**) * (m_MinifigCount+1)); for (i = 0; i < m_MinifigCount; i++) { @@ -829,7 +829,7 @@ void MinifigWizard::Calculate () m3.Translate (pos[LC_MFW_LEFT_SHOE][0]-pos[LC_MFW_LEFT_LEG][0], pos[LC_MFW_LEFT_SHOE][1]-pos[LC_MFW_LEFT_LEG][1], pos[LC_MFW_LEFT_SHOE][2]-pos[LC_MFW_LEFT_LEG][2]); - if (strcmp (m_Info[LC_MFW_LEFT_LEG]->m_strName, "773") == 0) + if (m_Info[LC_MFW_LEFT_LEG] && strcmp(m_Info[LC_MFW_LEFT_LEG]->m_strName, "773") == 0) m3.Translate (-0.8f, 0, 0); mat.CreateOld (0,0,0,rot[LC_MFW_LEFT_SHOE][0]-rot[LC_MFW_LEFT_LEG][0], rot[LC_MFW_LEFT_SHOE][1]-rot[LC_MFW_LEFT_LEG][1], diff --git a/common/object.cpp b/common/object.cpp index 1b8a91c..88e1f6c 100755 --- a/common/object.cpp +++ b/common/object.cpp @@ -250,7 +250,10 @@ void Object::CalculateKeys (unsigned short nTime, bool bAnimation) int i, empty = m_nKeyInfoCount; for (i = 0; i < m_nKeyInfoCount; i++) + { next[i] = NULL; + prev[i] = NULL; + } if (bAnimation) node = m_pAnimationKeys; @@ -281,6 +284,8 @@ void Object::CalculateKeys (unsigned short nTime, bool bAnimation) { LC_OBJECT_KEY *n = next[i], *p = prev[i]; + if (p == NULL) continue; + if (bAnimation && (n != NULL) && (p->time != nTime)) { float t = (float)(nTime - p->time)/(n->time - p->time); diff --git a/common/pieceinf.cpp b/common/pieceinf.cpp index eee37e4..45ea2ce 100644 --- a/common/pieceinf.cpp +++ b/common/pieceinf.cpp @@ -350,7 +350,7 @@ void PieceInfo::LoadInformation() // Read connections m_nConnectionCount = LCUINT16(*((lcuint16*)bytes)); bytes += sizeof (lcuint16); - m_pConnections = (CONNECTIONINFO*)malloc (m_nConnectionCount * sizeof(CONNECTIONINFO)); + m_pConnections = (CONNECTIONINFO*)malloc((m_nConnectionCount+1) * sizeof(CONNECTIONINFO)); sh = m_nConnectionCount; for (pConnection = m_pConnections; sh--; pConnection++) -- cgit v1.2.3