[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-dev] [patch] server/font.cpp: proper memory deletion
From: |
Bastiaan Jacques |
Subject: |
[Gnash-dev] [patch] server/font.cpp: proper memory deletion |
Date: |
Thu, 20 Apr 2006 21:45:14 +0200 |
User-agent: |
KMail/1.9.1 |
Hi,
The attached patch fixes the use of operator delete in server/font.cpp.
The first chunk removes the NULL check, because operator delete[] does
it already. The NULL-ing out of m_name is also unneeded, because m_name
is about to go away, and accessing after destruction should fail anyway.
But the more important bit is the second chunk, where operator delete is
used where operator delete [] is needed. The behaviour of calling delete
on a pointer which was returned by operator new[] is undefined.
--
Bastiaan
Index: server/font.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/font.cpp,v
retrieving revision 1.6
diff -p -u -r1.6 font.cpp
--- server/font.cpp 26 Feb 2006 21:44:53 -0000 1.6
+++ server/font.cpp 20 Apr 2006 19:38:02 -0000
@@ -37,11 +37,7 @@ namespace gnash {
m_glyphs.resize(0);
// Delete the name string.
- if (m_name)
- {
- delete [] m_name;
- m_name = NULL;
- }
+ delete [] m_name;
}
shape_character_def* font::get_glyph(int index) const
@@ -297,11 +293,7 @@ namespace gnash {
// DefineFontInfo tag. The caller has already read the tag
// type and font id.
{
- if (m_name)
- {
- delete m_name;
- m_name = NULL;
- }
+ delete [] m_name;
m_name = in->read_string_with_length();
- [Gnash-dev] [patch] server/font.cpp: proper memory deletion,
Bastiaan Jacques <=