From 769d2a531b9b685b97f20395b2333c0416503e16 Mon Sep 17 00:00:00 2001 From: terryky Date: Wed, 19 Jun 2019 10:14:01 +0900 Subject: [PATCH] fix buffer overrun of "std::vector sorted_indices". In DecreasingPartialArgSort() function, up to (num_boxes + max_detections) elements of sorted_indices will be overwritten. However, sorted_indices has only (max_detections) capacity, so that It cause buffer overrun. So I increased the size of sorted_indices. --- tensorflow/lite/kernels/detection_postprocess.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorflow/lite/kernels/detection_postprocess.cc b/tensorflow/lite/kernels/detection_postprocess.cc index 8285b4d9b84..6055070af40 100644 --- a/tensorflow/lite/kernels/detection_postprocess.cc +++ b/tensorflow/lite/kernels/detection_postprocess.cc @@ -498,7 +498,7 @@ TfLiteStatus NonMaxSuppressionMultiClassRegularHelper(TfLiteContext* context, int size_of_sorted_indices = 0; std::vector sorted_indices; - sorted_indices.resize(max_detections); + sorted_indices.resize(num_boxes + max_detections); std::vector sorted_values; sorted_values.resize(max_detections);