Skip to content

Commit

Permalink
crnlib: attempt to fix CodeQL reports
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed Jul 6, 2024
1 parent a386984 commit ed5344a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions crnlib/crn_jpgd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2441,7 +2441,7 @@ jpeg_decoder::coeff_buf* jpeg_decoder::coeff_buf_open(int block_num_x, int block
cb->block_len_x = block_len_x;
cb->block_len_y = block_len_y;
cb->block_size = (block_len_x * block_len_y) * sizeof(jpgd_block_t);
cb->pData = (uint8*)alloc(cb->block_size * block_num_x * block_num_y, true);
cb->pData = (uint8*)alloc((size_t)cb->block_size * (size_t)block_num_x * (size_t)block_num_y, true);
return cb;
}

Expand Down Expand Up @@ -2870,7 +2870,7 @@ unsigned char* decompress_jpeg_image_from_stream(jpeg_decoder_stream* pStream, i

const int dst_bpl = image_width * req_comps;

uint8* pImage_data = (uint8*)jpgd_malloc(dst_bpl * image_height);
uint8* pImage_data = (uint8*)jpgd_malloc((size_t)dst_bpl * (size_t)image_height);
if (!pImage_data)
return NULL;

Expand Down
2 changes: 1 addition & 1 deletion crnlib/crn_jpge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ bool jpeg_encoder::jpg_open(int p_x_res, int p_y_res, int src_channels) {
m_image_bpl_mcu = m_image_x_mcu * m_num_components;
m_mcus_per_row = m_image_x_mcu / m_mcu_x;

if ((m_mcu_lines[0] = static_cast<uint8*>(jpge_malloc(m_image_bpl_mcu * m_mcu_y))) == NULL)
if ((m_mcu_lines[0] = static_cast<uint8*>(jpge_malloc((size_t)m_image_bpl_mcu * (size_t)m_mcu_y))) == NULL)
return false;
for (int i = 1; i < m_mcu_y; i++)
m_mcu_lines[i] = m_mcu_lines[i - 1] + m_image_bpl_mcu;
Expand Down
2 changes: 1 addition & 1 deletion crnlib/crn_threaded_clusterizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class threaded_clusterizer {
double sum = 0;

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

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

Expand Down
4 changes: 2 additions & 2 deletions crnlib/crn_tree_clusterizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class tree_clusterizer {
m_weightedVectors[i] = v * (float)weight;
root.m_centroid += m_weightedVectors[i];
root.m_total_weight += weight;
m_weightedDotProducts[i] = v.dot(v) * weight;
m_weightedDotProducts[i] = (double)v.dot(v) * (double)weight;
ttsum += m_weightedDotProducts[i];
}
root.m_variance = (float)(ttsum - (root.m_centroid.dot(root.m_centroid) / root.m_total_weight));
Expand Down Expand Up @@ -289,7 +289,7 @@ class tree_clusterizer {
double sum = 0;

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

x[i] = (float)sum;

Expand Down

0 comments on commit ed5344a

Please sign in to comment.