Skip to content

Commit ed5344a

Browse files
committed
crnlib: attempt to fix CodeQL reports
1 parent a386984 commit ed5344a

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

crnlib/crn_jpgd.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2441,7 +2441,7 @@ jpeg_decoder::coeff_buf* jpeg_decoder::coeff_buf_open(int block_num_x, int block
24412441
cb->block_len_x = block_len_x;
24422442
cb->block_len_y = block_len_y;
24432443
cb->block_size = (block_len_x * block_len_y) * sizeof(jpgd_block_t);
2444-
cb->pData = (uint8*)alloc(cb->block_size * block_num_x * block_num_y, true);
2444+
cb->pData = (uint8*)alloc((size_t)cb->block_size * (size_t)block_num_x * (size_t)block_num_y, true);
24452445
return cb;
24462446
}
24472447

@@ -2870,7 +2870,7 @@ unsigned char* decompress_jpeg_image_from_stream(jpeg_decoder_stream* pStream, i
28702870

28712871
const int dst_bpl = image_width * req_comps;
28722872

2873-
uint8* pImage_data = (uint8*)jpgd_malloc(dst_bpl * image_height);
2873+
uint8* pImage_data = (uint8*)jpgd_malloc((size_t)dst_bpl * (size_t)image_height);
28742874
if (!pImage_data)
28752875
return NULL;
28762876

crnlib/crn_jpge.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ bool jpeg_encoder::jpg_open(int p_x_res, int p_y_res, int src_channels) {
576576
m_image_bpl_mcu = m_image_x_mcu * m_num_components;
577577
m_mcus_per_row = m_image_x_mcu / m_mcu_x;
578578

579-
if ((m_mcu_lines[0] = static_cast<uint8*>(jpge_malloc(m_image_bpl_mcu * m_mcu_y))) == NULL)
579+
if ((m_mcu_lines[0] = static_cast<uint8*>(jpge_malloc((size_t)m_image_bpl_mcu * (size_t)m_mcu_y))) == NULL)
580580
return false;
581581
for (int i = 1; i < m_mcu_y; i++)
582582
m_mcu_lines[i] = m_mcu_lines[i - 1] + m_image_bpl_mcu;

crnlib/crn_threaded_clusterizer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ class threaded_clusterizer {
219219
double sum = 0;
220220

221221
for (uint j = 0; j < N; j++)
222-
sum += axis[j] * covar[i][j];
222+
sum += static_cast<double>(axis[j]) * static_cast<double>(covar[i][j]);
223223

224224
x[i] = static_cast<float>(sum);
225225

crnlib/crn_tree_clusterizer.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class tree_clusterizer {
7272
m_weightedVectors[i] = v * (float)weight;
7373
root.m_centroid += m_weightedVectors[i];
7474
root.m_total_weight += weight;
75-
m_weightedDotProducts[i] = v.dot(v) * weight;
75+
m_weightedDotProducts[i] = (double)v.dot(v) * (double)weight;
7676
ttsum += m_weightedDotProducts[i];
7777
}
7878
root.m_variance = (float)(ttsum - (root.m_centroid.dot(root.m_centroid) / root.m_total_weight));
@@ -289,7 +289,7 @@ class tree_clusterizer {
289289
double sum = 0;
290290

291291
for (uint j = 0; j < N; j++)
292-
sum += axis[j] * covar[i][j];
292+
sum += (double)axis[j] * (double)covar[i][j];
293293

294294
x[i] = (float)sum;
295295

0 commit comments

Comments
 (0)