0001-Use-the-one-argument-version-of-SetTotalBytesLimit.patch 1.5 KB

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