Skip to content

Commit

Permalink
Merge pull request cddlib#21 from mcmtroffaes/feature/fix-free-segfau…
Browse files Browse the repository at this point in the history
…lt-on-empty-matrix

Ensure pointers are properly initialized even on zero length allocation.
  • Loading branch information
saraedum authored Oct 23, 2018
2 parents dc81555 + d7bbc21 commit 0644cc2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib-src/cddcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ void dd_InitializeArow(dd_colrange d,dd_Arow *a)
{
dd_colrange j;

if (d>0) *a=(mytype*) calloc(d,sizeof(mytype));
*a=(mytype*) calloc(d,sizeof(mytype));
for (j = 0; j < d; j++) {
dd_init((*a)[j]);
}
Expand All @@ -703,7 +703,7 @@ void dd_InitializeAmatrix(dd_rowrange m,dd_colrange d,dd_Amatrix *A)
{
dd_rowrange i;

if (m>0) (*A)=(mytype**) calloc(m,sizeof(mytype*));
(*A)=(mytype**) calloc(m,sizeof(mytype*));
for (i = 0; i < m; i++) {
dd_InitializeArow(d,&((*A)[i]));
}
Expand Down

0 comments on commit 0644cc2

Please sign in to comment.