Skip to content

Commit

Permalink
Merge pull request #1519 from ampli/count-ovfl-fix
Browse files Browse the repository at this point in the history
count.c: Bugfix count ovfl in recent refactoring
  • Loading branch information
linas authored May 3, 2024
2 parents 0f9ae60 + 74c19b1 commit f393ef5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions link-grammar/parse/count.c
Original file line number Diff line number Diff line change
Expand Up @@ -1079,14 +1079,18 @@ static Count_bin do_count(const char dlabel[], count_context_t *ctxt,
* the scenario of using two "multi" end connectors simultaneously
* has not been encountered with the included dictionaries.
*
* To enable 31-bit overflow detection, totcount is signed 64-bit. The
* ccount array values are already clamped values. So the result will
* never be more than 4*2^31 which is less than 2^63-1.
*
* @return Sum of the counts as mentioned above.
*/
static Count_bin scount(const char dlabel[], count_context_t *ctxt,
Count_bin ccount[4], int lw, int rw,
Connector *le, Connector *re,
unsigned int null_count)
static w_Count_bin scount(const char dlabel[], count_context_t *ctxt,
Count_bin ccount[4], int lw, int rw,
Connector *le, Connector *re,
unsigned int null_count)
{
Count_bin totcount;
w_Count_bin totcount;

CACHE_COUNT(ccount[0], totcount = count,
do_count(dlabel, ctxt, lw, rw, le->next, re->next, null_count));
Expand Down

0 comments on commit f393ef5

Please sign in to comment.