niessner / mLib

Research Library used in the Visual Computing Lab
http://niessnerlab.org
MIT License
89 stars 45 forks source link

error in baseImage::loadFromBinaryMImage #4

Closed yscoffee closed 6 years ago

yscoffee commented 6 years ago

https://github.com/niessner/mLib/blob/7ca7eaaf8ea84ed6d959f654bf06e2e4cedebdee/include/core-base/baseImage.h#L568

looks this line should be SAFE_DELETE_ARRAY(data); =>SAFE_DELETE_ARRAY(*data);

niessner commented 6 years ago

I'm pretty sure SAFE_DELETE_ARRAY(data) should be correct. You certainly don't want to dereference your data ptr here...

yscoffee commented 6 years ago

in general, yes

but data in L568 points to a pointer not a data block, no ? safe-delete action will actually remove the pointer see loadFromBinaryMImage :

void loadFromBinaryMImage(const std::string& filename) {
    loadBinaryMImage(filename, (void**) & m_data , m_width, m_height);
}
static void loadBinaryMImage(const std::string& filename, void** data, unsigned int& width, unsigned int& height) {
                ...
        SAFE_DELETE_ARRAY(data);
        *data = dataArray[0];
    }