Skip to content

Commit

Permalink
Update lusol.c (CRAN valgrid issue)
Browse files Browse the repository at this point in the history
valgrind reporting a realloc(3) call with size = 0
  • Loading branch information
vissarion committed Sep 18, 2023
1 parent 37d7c84 commit f9d64d5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R-proj/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Description: Provides an R interface for 'volesti' C++ package. 'volesti' comput
for sampling, rounding and rotating polytopes. Moreover, 'volesti' provides algorithms for
estimating copulas useful in computational finance. Methods implemented in 'volesti' are described
in A. Chalkis and V. Fisikopoulos (2022) <doi:10.32614/RJ-2021-077> and references therein.
Version: 1.1.2-6
Date: 2023-04-11
Version: 1.1.2-7
Date: 2023-10-18
Maintainer: Vissarion Fisikopoulos <vissarion.fisikopoulos@gmail.com>
Depends: Rcpp (>= 0.12.17)
Imports: methods, stats
Expand Down
11 changes: 11 additions & 0 deletions R-proj/src/Rproj_externals/lp_solve/lusol.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ void *clean_realloc(void *oldptr, int width, int newsize, int oldsize)
{
newsize *= width;
oldsize *= width;
/* this works around valgrind reporting a realloc(3) call with size = 0.
According to https://linux.die.net/man/3/realloc glibc frees the
memory in this case, and (maybe?) returns NULL:
> if size is equal to zero, and ptr is not NULL, then the call
> is equivalent to free(ptr). */
#ifdef __linux__
if (oldptr != NULL && newsize == 0) {
free(oldptr);
return NULL;
}
#endif
oldptr = LUSOL_REALLOC(oldptr, newsize);
if(newsize > oldsize)
/* MEMCLEAR(oldptr+oldsize, newsize-oldsize); */
Expand Down
4 changes: 4 additions & 0 deletions cran_gen/NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@
# volesti 1.1.2-6

- Fix UBSAN issues (lp_presolve)

# volesti 1.1.2-7

- Fix valgrind reporting a realloc(3) call with size = 0 (lp_presolve)

0 comments on commit f9d64d5

Please sign in to comment.