Merge pull request #27486 from asmorkalov:as/qrcode_encode_java_ub_fix

Fixed out-of-bound access issue in QR Encoder Java warappers
This commit is contained in:
Alexander Smorkalov 2025-06-27 08:17:32 +03:00 committed by GitHub
commit 3ff2ce3291
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -34,8 +34,9 @@
" LOGD(\"%s\", method_name);",
" Ptr<cv::QRCodeEncoder>* me = (Ptr<cv::QRCodeEncoder>*) self; //TODO: check for NULL",
" const char* n_encoded_info = reinterpret_cast<char*>(env->GetByteArrayElements(encoded_info, NULL));",
" const jsize n_encoded_info_size = env->GetArrayLength(encoded_info);",
" Mat& qrcode = *((Mat*)qrcode_nativeObj);",
" (*me)->encode( n_encoded_info, qrcode );",
" (*me)->encode( std::string(n_encoded_info, n_encoded_info_size), qrcode );",
" } catch(const std::exception &e) {",
" throwJavaException(env, &e, method_name);",
" } catch (...) {",