Skip to content

Commit

Permalink
numaGetCount(): make sure surrounding code/variables are properly pre…
Browse files Browse the repository at this point in the history
…-initialized to cope with the fringe case where the NUMA histogram is empty (count = 0)

(Discovered through code review & accidental misuse in vitro (when I fed numaHistogramGetValFromRank() an empty histogram by accident).)
  • Loading branch information
GerHobbelt committed Aug 24, 2023
1 parent eaaf52f commit 9d7ecbe
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,7 @@ PTA *pta1, *pta2, *ptad;

/* Generate the plot points */
pta1 = ptaCreate(n);
maxw = maxh = 0;
for (i = 0; i < n; i++) {
numaGetFValue(na, i, &val);
if (orient == L_HORIZONTAL_LINE) {
Expand Down
1 change: 1 addition & 0 deletions src/numafunc2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1613,6 +1613,7 @@ l_float32 startval, binsize, rankcount, total, sum, fract, val;
numaGetSum(na, &total);
rankcount = rank * total; /* count that corresponds to rank */
sum = 0.0;
val = 0.0;
for (i = 0; i < n; i++) {
numaGetFValue(na, i, &val);
if (sum + val >= rankcount)
Expand Down

0 comments on commit 9d7ecbe

Please sign in to comment.