From 7830b3da42a41db25b4c57efbf2bd0c63e7d97f4 Mon Sep 17 00:00:00 2001 From: nihuini Date: Tue, 22 Aug 2017 16:31:54 +0800 Subject: [PATCH] fix potential overread when bias_term is zero --- src/layer/arm/convolutiondepthwise_arm.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/layer/arm/convolutiondepthwise_arm.cpp b/src/layer/arm/convolutiondepthwise_arm.cpp index c36453e03..7a04f8ea4 100644 --- a/src/layer/arm/convolutiondepthwise_arm.cpp +++ b/src/layer/arm/convolutiondepthwise_arm.cpp @@ -144,7 +144,9 @@ int ConvolutionDepthWise_arm::forward(const Mat& bottom_blob, Mat& top_blob) con Mat bottom_blob_bordered_g = bottom_blob_bordered.channel(g); Mat top_blob_g = top_blob.channel(g); Mat weight_data_g(maxk, (float*)(weight_data + maxk * g)); - Mat bias_data_g(1, (float*)(bias_data + g)); + Mat bias_data_g; + if (bias_term) + bias_data_g = Mat(1, (float*)(bias_data + g)); conv(bottom_blob_bordered_g, top_blob_g, weight_data_g, bias_data_g); } @@ -163,7 +165,9 @@ int ConvolutionDepthWise_arm::forward(const Mat& bottom_blob, Mat& top_blob) con Mat bottom_blob_bordered_g(w, h, channels_g, bottom_blob_bordered.channel(channels_g * g)); Mat top_blob_g(outw, outh, num_output_g, top_blob.channel(num_output_g * g)); Mat weight_data_g(maxk * channels_g * num_output_g, (float*)(weight_data + maxk * channels_g * num_output_g * g)); - Mat bias_data_g(num_output_g, (float*)(bias_data + num_output_g * g)); + Mat bias_data_g; + if (bias_term) + bias_data_g = Mat(num_output_g, (float*)(bias_data + num_output_g * g)); conv(bottom_blob_bordered_g, top_blob_g, weight_data_g, bias_data_g); }