1 Star 0 Fork 56

gice/tensorflow

forked from openEuler-RISC-V/tensorflow
关闭
 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CVE-2021-29590.patch 3.17 KB
一键复制 编辑 原始数据 按行查看 历史
From 953f28dca13c92839ba389c055587cfe6c723578 Mon Sep 17 00:00:00 2001
From: Mihai Maruseac <mihaimaruseac@google.com>
Date: Tue, 27 Apr 2021 17:46:38 -0700
Subject: [PATCH] Prevent a null pointer exception in TFLite
PiperOrigin-RevId: 370800206
Change-Id: Idd437ebce4ff224120d8eefc1c14c062173b71d6
---
tensorflow/lite/kernels/maximum_minimum.cc | 60 +++++++++++-----------
1 file changed, 31 insertions(+), 29 deletions(-)
diff --git a/tensorflow/lite/kernels/maximum_minimum.cc b/tensorflow/lite/kernels/maximum_minimum.cc
index 777e51442f120..176e020a5a8e5 100644
--- a/tensorflow/lite/kernels/maximum_minimum.cc
+++ b/tensorflow/lite/kernels/maximum_minimum.cc
@@ -157,35 +157,37 @@ template <KernelType kernel_type, typename OpType>
TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {
OpContext op_context(context, node);
- switch (op_context.output->type) {
- case kTfLiteFloat32:
- TFLiteOperation<kernel_type, float, OpType>(context, node, op_context);
- break;
- case kTfLiteUInt8:
- TFLiteOperation<kernel_type, uint8_t, OpType>(context, node,
- op_context);
- break;
- case kTfLiteInt8:
- TFLiteOperation<kernel_type, int8_t, OpType>(context, node, op_context);
- break;
- case kTfLiteInt32:
- TFLiteOperation<kernel_type, int32_t, OpType>(context, node,
- op_context);
- break;
- case kTfLiteInt64:
- TFLiteOperation<kernel_type, int64_t, OpType>(context, node,
- op_context);
- break;
- case kTfLiteInt16:
- TFLiteOperation<kernel_type, int16_t, OpType>(context, node,
- op_context);
- break;
- default:
- context->ReportError(context,
- "Type %d is currently not supported by Maximum.",
- op_context.output->type);
- return kTfLiteError;
- }
+ // If inputs have no element, shortcircuit.
+ if (NumElements(op_context.input1) == 0 ||
+ NumElements(op_context.input2) == 0) {
+ return kTfLiteOk;
+ }
+
+ switch (op_context.output->type) {
+ case kTfLiteFloat32:
+ TFLiteOperation<kernel_type, float, OpType>(context, node, op_context);
+ break;
+ case kTfLiteUInt8:
+ TFLiteOperation<kernel_type, uint8_t, OpType>(context, node, op_context);
+ break;
+ case kTfLiteInt8:
+ TFLiteOperation<kernel_type, int8_t, OpType>(context, node, op_context);
+ break;
+ case kTfLiteInt32:
+ TFLiteOperation<kernel_type, int32_t, OpType>(context, node, op_context);
+ break;
+ case kTfLiteInt64:
+ TFLiteOperation<kernel_type, int64_t, OpType>(context, node, op_context);
+ break;
+ case kTfLiteInt16:
+ TFLiteOperation<kernel_type, int16_t, OpType>(context, node, op_context);
+ break;
+ default:
+ context->ReportError(context,
+ "Type %d is currently not supported by Maximum.",
+ op_context.output->type);
+ return kTfLiteError;
+ }
return kTfLiteOk;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gice/tensorflow.git
git@gitee.com:gice/tensorflow.git
gice
tensorflow
tensorflow
master

搜索帮助