khoren93 / flutter_zxing

Flutter plugin for scanning and generating QR codes using the ZXing library, supporting Android, iOS, and desktop platforms
https://pub.dev/packages/flutter_zxing
MIT License
88 stars 50 forks source link

ffi: fix use-after-free #140

Closed phlip9 closed 1 month ago

phlip9 commented 2 months ago

The ImageView borrows from the image buffer in DecodeBarcodeParams -- the newly refactored code frees it too early.

To help prevent some of these issues in the future, we'll be a bit clearer that DecodeBarcodeParams owns the buffer and actually free it in the destructor. Same with EncodeBarcodeParams and contents.

I've also disabled the copy/move constructors so we don't accidentally double free or free a nullptr.

phlip9 commented 1 month ago

cc @khoren93

khoren93 commented 1 month ago

@phlip9 Thanks!