c++ - Program crashes while destructor calls delete function -


i working large code , program crashes, when destructor called. specifying place, fails:

application::~application() {   ( int blockid=0; blockid< m_noblocks; blockid++ ) {     if ( m_blocks[ blockid ] ) {       delete m_blocks[ blockid ];  //error here       m_blocks[ blockid ] = null;     }     if ( m_methods[ blockid ] ) {       delete m_methods[ blockid ];       m_methods[ blockid ] = null;     }   } } 

the program crashes @ delete operation mentioned @ 'error here'. however, if comment line, program seems work fine. throw light, possible problem?

edit: allocated in constructor using new. m_noblocks defined value , not specified here:

application::application(){       m_blocks = new zfsblock*[m_noblocks];       m_methods = new zfsmethods*[m_noblocks];        ( int blockid=0; blockid< m_noblocks; blockid++ ) {         m_methods[ blockid ] = null;         m_blocks[ blockid ] = null;       } } 

however, there actual assignment of m_methods , m_blocks inside main part of code later.

m_noblocks left uninitialized, no 1 can predict how many pointers have space store.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -