Skip to content

Commit 904b221

Browse files
authored
Add cast to prevent overflow of intermediate result
1 parent 3a30c12 commit 904b221

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

interface/imatcopy.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ void CNAME( enum CBLAS_ORDER CORDER, enum CBLAS_TRANSPOSE CTRANS, blasint crows,
150150
#endif
151151

152152
if ( *lda > *ldb )
153-
msize = (*lda) * (*ldb) * sizeof(FLOAT);
153+
msize = (size_t)(*lda) * (*ldb) * sizeof(FLOAT);
154154
else
155-
msize = (*ldb) * (*ldb) * sizeof(FLOAT);
155+
msize = (size_t)(*ldb) * (*ldb) * sizeof(FLOAT);
156156

157157
b = malloc(msize);
158158
if ( b == NULL )

interface/zimatcopy.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ void CNAME( enum CBLAS_ORDER CORDER, enum CBLAS_TRANSPOSE CTRANS, blasint crows,
172172
#endif
173173

174174
if ( *lda > *ldb )
175-
msize = (*lda) * (*ldb) * sizeof(FLOAT) * 2;
175+
msize = (size_t)(*lda) * (*ldb) * sizeof(FLOAT) * 2;
176176
else
177-
msize = (*ldb) * (*ldb) * sizeof(FLOAT) * 2;
177+
msize = (size_t)(*ldb) * (*ldb) * sizeof(FLOAT) * 2;
178178

179179
b = malloc(msize);
180180
if ( b == NULL )

0 commit comments

Comments
 (0)