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

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -