Skip to content

Commit 1c8f1ba

Browse files
authored
Fixed LGTM warnings (Tencent#3891)
src/stb_image.h src/layer/detectionoutput.cpp tools/quantize/imreadwrite.cpp
1 parent 2e73a4c commit 1c8f1ba

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/layer/detectionoutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ int DetectionOutput::forward(const std::vector<Mat>& bottom_blobs, std::vector<M
170170
for (int i = 0; i < num_prior; i++)
171171
{
172172
// if score of background class is larger than confidence threshold
173-
float score = mxnet_ssd_style ? confidence[i] : confidence[i * num_class_copy];
173+
float score = mxnet_ssd_style ? confidence[i] : confidence[static_cast<size_t>(i) * static_cast<size_t>(num_class_copy)];
174174
if (score >= (1.0 - confidence_threshold))
175175
{
176176
continue;

src/stb_image.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1756,7 +1756,8 @@ static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int r
17561756
if (req_comp == img_n) return data;
17571757
STBI_ASSERT(req_comp >= 1 && req_comp <= 4);
17581758

1759-
good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2);
1759+
const size_t alloc_size = static_cast<size_t>(req_comp) * static_cast<size_t>(x) * static_cast<size_t>(y) * 2;
1760+
good = (stbi__uint16 *) stbi__malloc(alloc_size);
17601761
if (good == NULL) {
17611762
STBI_FREE(data);
17621763
return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory");

tools/quantize/imreadwrite.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ Mat imread(const std::string& path, int flags)
8686
return Mat();
8787
}
8888

89-
memcpy(img.data, pixeldata, w * h * c);
89+
memcpy(img.data, pixeldata, static_cast<size_t>(w) * static_cast<size_t>(h) * static_cast<size_t>(c));
9090

9191
stbi_image_free(pixeldata);
9292

0 commit comments

Comments
 (0)