[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-freeqt
Subject: [freeqt] What's wrong with this delete[]??
From: Jorgen Sigvardsson <jorgen () petrov ! sax ! hks ! se>
Date: 1998-09-28 20:16:25
[Download RAW message or body]
In QLineEditBuf I have a member function called 'grow()' wich is called
whenever the char-buffer needs to grow. It looks like this:
void QLineEditBuffer::grow() {
char* new_buf;
new_buf = new char[m_bufsize + BUF_GROWBY + 1];
memcpy(new_buf, m_buf, m_glyphsused);
delete [] m_buf;
m_buf = new_buf;
m_bufsize += BUF_GROWBY;
m_bufsize++; // Take the first buffers \0 character into account.
}
I cannot seen anything particularly wrong with this (except that memory is not
realloc()ated).
The program crashes when it tries to free m_buf (internal character buffer):
#0 0x40366c72 in free ()
#1 0x40366b31 in free ()
#2 0x400d9566 in ___builtin_delete (ptr=0x8054248)
#3 0x400d95e2 in ___builtin_vec_delete (ptr=0x8054248)
#4 0x400d4766 in QLineEditBuffer::grow (this=0xbffff3a0) at qlineedbuf.cc:233
A quick grep through qlineedbuf.cc on m_buf, I cannot see that I am modifying
m_buf in other
places than a) constructor/destructor and b) grow(). Am I going insane?
--
Jorgen Sigvardsson - Consultant@WM-data Sweden.
(I do not speak for my employer nor do they speak for me)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic