Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

count.c: Bugfix count ovfl in recent refactoring #1519

Merged
merged 1 commit into from
May 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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