Skip to content

Commit

Permalink
Clean method UNICHARSET::add_script
Browse files Browse the repository at this point in the history
It increased the script_table too early, so the last element was never
used.

Signed-off-by: Stefan Weil <[email protected]>
  • Loading branch information
stweil committed May 13, 2017
1 parent af212af commit 69296f8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions ccutil/unicharset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,13 +1009,13 @@ int UNICHARSET::add_script(const char* script) {
if (script_table_size_reserved == 0) {
script_table_size_reserved = 8;
script_table = new char*[script_table_size_reserved];
}
if (script_table_size_used + 1 >= script_table_size_reserved) {
char** new_script_table = new char*[script_table_size_reserved * 2];
memcpy(new_script_table, script_table, script_table_size_reserved * sizeof(char*));
} else if (script_table_size_used >= script_table_size_reserved) {
assert(script_table_size_used == script_table_size_reserved);
script_table_size_reserved += script_table_size_reserved;
char** new_script_table = new char*[script_table_size_reserved];
memcpy(new_script_table, script_table, script_table_size_used * sizeof(char*));
delete[] script_table;
script_table = new_script_table;
script_table_size_reserved = 2 * script_table_size_reserved;
}
script_table[script_table_size_used] = new char[strlen(script) + 1];
strcpy(script_table[script_table_size_used], script);
Expand Down

0 comments on commit 69296f8

Please sign in to comment.