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

Fix out-of-bounds read inside norm_inf by returning 0.0 for 0 len arra… #285

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/linalg.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,14 @@ scs_float SCS(norm_inf)(const scs_float *a, scs_int len) {
*/

scs_float SCS(norm_inf)(const scs_float *a, scs_int len) {
/* Follow the semantics of BLASI(lange) for zero-size array. */
scs_int idx;
blas_int bone = 1;
blas_int blen = (blas_int)len;
scs_int idx = (scs_int)BLASI(amax)(&blen, a, &bone);
if (len <= 0) {
return 0.0;
}
idx = (scs_int)BLASI(amax)(&blen, a, &bone);
/* Returned idx is 1-based. */
return ABS(a[idx - 1]);
}
Expand Down
Loading