Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test/gradients #302

Merged
merged 3 commits into from
Jan 16, 2025
Merged

Test/gradients #302

merged 3 commits into from
Jan 16, 2025

Conversation

paul-manias
Copy link
Member

No description provided.

@paul-manias paul-manias merged commit 059bdac into master Jan 16, 2025
1 check passed
@paul-manias paul-manias deleted the test/gradients branch January 16, 2025 23:40

// II. Distance Transform
// Create Float Buffer + 0 vs infinity (1e20) assignment
std::vector<double> image(width * height);

Check failure

Code scanning / CodeQL

Multiplication result converted to larger type High

Multiplication result may overflow 'int' before it is converted to 'size_type'.

Copilot Autofix AI 14 days ago

To fix the problem, we need to ensure that the multiplication is performed using a larger integer type to prevent overflow. We can achieve this by casting one of the operands to size_type before performing the multiplication. This will ensure that the multiplication is done using the larger type, and the result will be correctly converted to size_type.

  • Cast one of the operands (width or height) to size_type before performing the multiplication.
  • Update the initialization of the std::vector<double> to use the result of the multiplication with the cast.
Suggested changeset 1
src/vector/agg/include/agg_span_gradient_contour.h

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/vector/agg/include/agg_span_gradient_contour.h b/src/vector/agg/include/agg_span_gradient_contour.h
--- a/src/vector/agg/include/agg_span_gradient_contour.h
+++ b/src/vector/agg/include/agg_span_gradient_contour.h
@@ -140,3 +140,3 @@
 			// Create Float Buffer + 0 vs infinity (1e20) assignment
-			std::vector<double> image(width * height);
+			std::vector<double> image(static_cast<std::vector<double>::size_type>(width) * height);
 
EOF
@@ -140,3 +140,3 @@
// Create Float Buffer + 0 vs infinity (1e20) assignment
std::vector<double> image(width * height);
std::vector<double> image(static_cast<std::vector<double>::size_type>(width) * height);

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant