dropbox / lepton

Lepton is a tool and file format for losslessly compressing JPEGs by an average of 22%.
https://blogs.dropbox.com/tech/2016/07/lepton-image-compression-saving-22-losslessly-from-images-at-15mbs/
Apache License 2.0
5.01k stars 355 forks source link

(error) Using 'memset' on struct that contains a 'std::vector' #66

Closed bryonglodencissp closed 8 years ago

bryonglodencissp commented 8 years ago

Greetings. I found three issues, where memset is used on a struct that contains a std::vector. This can be dangerous and can lead to inconsistent memory (see discussion at http://stackoverflow.com/questions/6877281/memset-structure-with-stdstring-contained).

[src/vp8/util/block_context.hh:92]: (error) Using 'memset' on struct that contains a 'std::vector'.
[src/vp8/util/block_context.hh:100]: (error) Using 'memset' on struct that contains a 'std::vector'.
[src/vp8/util/block_context.hh:123]: (error) Using 'memset' on struct that contains a 'std::vector'.

Found by https://github.com/bryongloden/cppcheck

danielrh commented 8 years ago

in this case it's std::vector<>::iterator so most compilers will represent it as a pointer... for which NULL won't cause memory corruption

That said: it's correctly identified as undefined behavior and I've got a patch to fix it... coming soon

bryonglodencissp commented 8 years ago

Thanks for correcting my typo 👍 And way to go (WTG) with your patch!