Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
bug fix to CHOLMOD postorder; invalid typecast if size_t is less than…
… sizeof(Int)
  • Loading branch information
DrTimothyAldenDavis committed Aug 1, 2023
1 parent 656695e commit 97d3b10
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions CHOLMOD/Cholesky/cholmod_postorder.c
Expand Up @@ -139,7 +139,7 @@ Int CHOLMOD(postorder) /* return # of nodes postordered */
(
/* ---- input ---- */
Int *Parent, /* size n. Parent [j] = p if p is the parent of j */
size_t n,
size_t n_input,
Int *Weight, /* size n, optional. Weight [j] is weight of node j */
/* ---- output --- */
Int *Post, /* size n. Post [k] = j is kth in postordered tree */
Expand All @@ -151,6 +151,15 @@ Int CHOLMOD(postorder) /* return # of nodes postordered */
Int j, p, k, w, nextj ;
size_t s ;
int ok = TRUE ;
Int n = (Int) n_input ;

// printf ("Here I am, sizeof(Int) %g\n", (double) sizeof (Int)) ;
// printf ("sizeof(Int *) %g\n", (double) sizeof (Int *)) ;
// #ifdef DLONG
// printf ("DLONG is defined\n") ;
// #endif
// printf ("n input: %g\n", (double) n_input) ;
// printf ("n: %g\n", (double) n) ;

/* ---------------------------------------------------------------------- */
/* check inputs */
Expand All @@ -166,7 +175,8 @@ Int CHOLMOD(postorder) /* return # of nodes postordered */
/* ---------------------------------------------------------------------- */

/* s = 2*n */
s = CHOLMOD(mult_size_t) (n, 2, &ok) ;
s = CHOLMOD(mult_size_t) (n_input, (size_t) 2, &ok) ;
// printf ("s %g\n", (double) s) ;
if (!ok)
{
ERROR (CHOLMOD_TOO_LARGE, "problem too large") ;
Expand Down

0 comments on commit 97d3b10

Please sign in to comment.