Skip to content

Commit 48fb8a7

Browse files
Security fuzz address sanitizer fix Bug #2 and #3 (microsoft#21528)
### Description Security fuzz test with address sanitizer found several bugs
1 parent 1ce1608 commit 48fb8a7

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

onnxruntime/contrib_ops/cpu/transformers/subgraph_gpt.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ Status GptSubgraph::Validate(const std::vector<const NodeArg*>& subgraph_inputs,
143143

144144
// Past state shape is like (2, batch_size, num_heads, past_seq_len, hidden_size/num_heads).
145145
const ONNX_NAMESPACE::TensorShapeProto* past_shape = subgraph_inputs[3]->Shape();
146+
ORT_RETURN_IF(past_shape == nullptr,
147+
"subgraph past state cannot be nullptr");
146148
ORT_RETURN_IF(past_shape->dim_size() != 5,
147149
"subgraph past state is expected to have 5 dimension, got ", past_shape->dim_size());
148150

onnxruntime/core/optimizer/attention_fusion.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ Status AttentionFusion::ApplyImpl(Graph& graph, bool& modified, int graph_level,
210210

211211
if ((node.GetOutputEdgesCount() >= 2 && node.GetOutputEdgesCount() <= 6) && // Add node.GetOutputEdgesCount() == 5/6 for distilbert
212212
graph_utils::IsSupportedOptypeVersionAndDomain(node, "LayerNormalization", {1, 17}, kOnnxDomain) &&
213-
graph_utils::IsSupportedProvider(node, GetCompatibleExecutionProviders())) {
213+
graph_utils::IsSupportedProvider(node, GetCompatibleExecutionProviders()) && node.InputDefs().size() > 2) {
214214
// Get hidden size from layer norm bias tensor shape.
215215
const NodeArg& layer_norm_bias = *(node.InputDefs()[2]);
216216
if (!optimizer_utils::IsShapeKnownOnAllDims(layer_norm_bias, 1)) {

0 commit comments

Comments
 (0)