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