1*4882a593SmuzhiyunFrom 9cfa84313c5833d7295fcf57be93d5d2aaadfd88 Mon Sep 17 00:00:00 2001 2*4882a593SmuzhiyunFrom: Vincent Rabaud <vrabaud@google.com> 3*4882a593SmuzhiyunDate: Sat, 10 Jul 2021 00:21:52 +0200 4*4882a593SmuzhiyunSubject: [PATCH] Use the one argument version of SetTotalBytesLimit. 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunThe two argument versions has been deprecated, cf 7*4882a593Smuzhiyunhttps://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.io.coded_stream 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun[Retrieved from: 10*4882a593Smuzhiyunhttps://github.com/opencv/opencv/commit/9cfa84313c5833d7295fcf57be93d5d2aaadfd88] 11*4882a593SmuzhiyunSigned-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> 12*4882a593Smuzhiyun--- 13*4882a593Smuzhiyun modules/dnn/src/caffe/caffe_io.cpp | 5 +++++ 14*4882a593Smuzhiyun 1 file changed, 5 insertions(+) 15*4882a593Smuzhiyun 16*4882a593Smuzhiyundiff --git a/modules/dnn/src/caffe/caffe_io.cpp b/modules/dnn/src/caffe/caffe_io.cpp 17*4882a593Smuzhiyunindex 2fc4d84f4604..ebecf95eea3a 100644 18*4882a593Smuzhiyun--- a/modules/dnn/src/caffe/caffe_io.cpp 19*4882a593Smuzhiyun+++ b/modules/dnn/src/caffe/caffe_io.cpp 20*4882a593Smuzhiyun@@ -92,6 +92,7 @@ 21*4882a593Smuzhiyun #ifdef HAVE_PROTOBUF 22*4882a593Smuzhiyun #include <google/protobuf/io/coded_stream.h> 23*4882a593Smuzhiyun #include <google/protobuf/io/zero_copy_stream_impl.h> 24*4882a593Smuzhiyun+#include <google/protobuf/stubs/common.h> 25*4882a593Smuzhiyun #include <google/protobuf/text_format.h> 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun #include <opencv2/core.hpp> 28*4882a593Smuzhiyun@@ -1111,7 +1112,11 @@ static const int kProtoReadBytesLimit = INT_MAX; // Max size of 2 GB minus 1 by 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun bool ReadProtoFromBinary(ZeroCopyInputStream* input, Message *proto) { 31*4882a593Smuzhiyun CodedInputStream coded_input(input); 32*4882a593Smuzhiyun+#if GOOGLE_PROTOBUF_VERSION >= 3006000 33*4882a593Smuzhiyun+ coded_input.SetTotalBytesLimit(kProtoReadBytesLimit); 34*4882a593Smuzhiyun+#else 35*4882a593Smuzhiyun coded_input.SetTotalBytesLimit(kProtoReadBytesLimit, 536870912); 36*4882a593Smuzhiyun+#endif 37*4882a593Smuzhiyun 38*4882a593Smuzhiyun return proto->ParseFromCodedStream(&coded_input); 39*4882a593Smuzhiyun } 40