1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 13:09:22 +00:00

Add two more assertions.

Suggested by Frank Wojcik.

* src/search.cc (Search::find_asso_values): Assert that a step's
_changing_count is positive.
This commit is contained in:
Bruno Haible
2025-04-20 11:56:45 +02:00
parent 07009de281
commit a3fc358838
2 changed files with 15 additions and 1 deletions

View File

@@ -1,3 +1,10 @@
2025-04-20 Bruno Haible <bruno@clisp.org>
Add two more assertions.
Suggested by Frank Wojcik.
* src/search.cc (Search::find_asso_values): Assert that a step's
_changing_count is positive.
2025-04-20 Bruno Haible <bruno@clisp.org>
Fix typo in comment.

View File

@@ -967,7 +967,7 @@ struct Partition
struct Step
{
/* The characters whose values are being determined in this step. */
unsigned int _changing_count;
unsigned int _changing_count; /* > 0 */
unsigned int * _changing;
/* Exclusive upper bound for the _asso_values[c] of this step.
A power of 2. */
@@ -1276,6 +1276,11 @@ Search::find_asso_values ()
if (undetermined[c] && !step->_undetermined[c])
changing[changing_count++] = c;
/* The set of changing characters is non-empty, since it contains
chosen_c. */
if (changing_count == 0)
abort ();
step->_changing = changing;
step->_changing_count = changing_count;
@@ -1344,6 +1349,8 @@ Search::find_asso_values ()
/* Initialize the asso_values[]. */
unsigned int k = step->_changing_count;
if (k == 0)
abort ();
for (unsigned int i = 0; i < k; i++)
{
unsigned int c = step->_changing[i];