Fix potential segfault from not allocating work array (Reference-LAPACK 836)
This commit is contained in:
parent
df88536d1c
commit
a757e1486f
|
@ -80,11 +80,14 @@ lapack_int LAPACKE_dgeesx( int matrix_layout, char jobvs, char sort,
|
||||||
/* Allocate memory for work arrays */
|
/* Allocate memory for work arrays */
|
||||||
if( LAPACKE_lsame( sense, 'b' ) || LAPACKE_lsame( sense, 'v' ) ) {
|
if( LAPACKE_lsame( sense, 'b' ) || LAPACKE_lsame( sense, 'v' ) ) {
|
||||||
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
|
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * 1 );
|
||||||
|
}
|
||||||
if( iwork == NULL ) {
|
if( iwork == NULL ) {
|
||||||
info = LAPACK_WORK_MEMORY_ERROR;
|
info = LAPACK_WORK_MEMORY_ERROR;
|
||||||
goto exit_level_1;
|
goto exit_level_1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
work = (double*)LAPACKE_malloc( sizeof(double) * lwork );
|
work = (double*)LAPACKE_malloc( sizeof(double) * lwork );
|
||||||
if( work == NULL ) {
|
if( work == NULL ) {
|
||||||
info = LAPACK_WORK_MEMORY_ERROR;
|
info = LAPACK_WORK_MEMORY_ERROR;
|
||||||
|
@ -97,9 +100,7 @@ lapack_int LAPACKE_dgeesx( int matrix_layout, char jobvs, char sort,
|
||||||
/* Release memory and exit */
|
/* Release memory and exit */
|
||||||
LAPACKE_free( work );
|
LAPACKE_free( work );
|
||||||
exit_level_2:
|
exit_level_2:
|
||||||
if( LAPACKE_lsame( sense, 'b' ) || LAPACKE_lsame( sense, 'v' ) ) {
|
|
||||||
LAPACKE_free( iwork );
|
LAPACKE_free( iwork );
|
||||||
}
|
|
||||||
exit_level_1:
|
exit_level_1:
|
||||||
if( LAPACKE_lsame( sort, 's' ) ) {
|
if( LAPACKE_lsame( sort, 's' ) ) {
|
||||||
LAPACKE_free( bwork );
|
LAPACKE_free( bwork );
|
||||||
|
|
|
@ -80,11 +80,14 @@ lapack_int LAPACKE_sgeesx( int matrix_layout, char jobvs, char sort,
|
||||||
/* Allocate memory for work arrays */
|
/* Allocate memory for work arrays */
|
||||||
if( LAPACKE_lsame( sense, 'b' ) || LAPACKE_lsame( sense, 'v' ) ) {
|
if( LAPACKE_lsame( sense, 'b' ) || LAPACKE_lsame( sense, 'v' ) ) {
|
||||||
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
|
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * liwork );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
iwork = (lapack_int*)LAPACKE_malloc( sizeof(lapack_int) * 1 );
|
||||||
|
}
|
||||||
if( iwork == NULL ) {
|
if( iwork == NULL ) {
|
||||||
info = LAPACK_WORK_MEMORY_ERROR;
|
info = LAPACK_WORK_MEMORY_ERROR;
|
||||||
goto exit_level_1;
|
goto exit_level_1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
work = (float*)LAPACKE_malloc( sizeof(float) * lwork );
|
work = (float*)LAPACKE_malloc( sizeof(float) * lwork );
|
||||||
if( work == NULL ) {
|
if( work == NULL ) {
|
||||||
info = LAPACK_WORK_MEMORY_ERROR;
|
info = LAPACK_WORK_MEMORY_ERROR;
|
||||||
|
@ -97,9 +100,7 @@ lapack_int LAPACKE_sgeesx( int matrix_layout, char jobvs, char sort,
|
||||||
/* Release memory and exit */
|
/* Release memory and exit */
|
||||||
LAPACKE_free( work );
|
LAPACKE_free( work );
|
||||||
exit_level_2:
|
exit_level_2:
|
||||||
if( LAPACKE_lsame( sense, 'b' ) || LAPACKE_lsame( sense, 'v' ) ) {
|
|
||||||
LAPACKE_free( iwork );
|
LAPACKE_free( iwork );
|
||||||
}
|
|
||||||
exit_level_1:
|
exit_level_1:
|
||||||
if( LAPACKE_lsame( sort, 's' ) ) {
|
if( LAPACKE_lsame( sort, 's' ) ) {
|
||||||
LAPACKE_free( bwork );
|
LAPACKE_free( bwork );
|
||||||
|
|
Loading…
Reference in New Issue