Commit 08643dc4 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

dwrite: Handle memory allocation failure in bidi_compute_bracket_pairs (cppcheck).

parent a89975f7
...@@ -632,23 +632,27 @@ static BracketPair *bidi_compute_bracket_pairs(IsolatedRun *iso_run) ...@@ -632,23 +632,27 @@ static BracketPair *bidi_compute_bracket_pairs(IsolatedRun *iso_run)
WCHAR *open_stack; WCHAR *open_stack;
int *stack_index; int *stack_index;
int stack_top = iso_run->length; int stack_top = iso_run->length;
BracketPair *out = NULL; BracketPair *out;
int pair_count = 0; int pair_count = 0;
int i; int i;
open_stack = malloc(sizeof(WCHAR) * iso_run->length); open_stack = malloc(sizeof(WCHAR) * iso_run->length);
stack_index = malloc(sizeof(int) * iso_run->length); stack_index = malloc(sizeof(int) * iso_run->length);
out = malloc(sizeof(BracketPair) * iso_run->length);
if (!open_stack || !stack_index || !out) {
free(open_stack);
free(stack_index);
free(out);
return NULL;
}
out[0].start = -1;
for (i = 0; i < iso_run->length; i++) { for (i = 0; i < iso_run->length; i++) {
unsigned short ubv = get_table_entry_16(bidi_bracket_table, iso_run->item[i].ch); unsigned short ubv = get_table_entry_16(bidi_bracket_table, iso_run->item[i].ch);
if (ubv) if (ubv)
{ {
if (!out)
{
out = malloc(sizeof(BracketPair));
out[0].start = -1;
}
if ((ubv >> 8) == 0) { if ((ubv >> 8) == 0) {
stack_top--; stack_top--;
open_stack[stack_top] = iso_run->item[i].ch + (signed char)(ubv & 0xff); open_stack[stack_top] = iso_run->item[i].ch + (signed char)(ubv & 0xff);
...@@ -668,7 +672,6 @@ static BracketPair *bidi_compute_bracket_pairs(IsolatedRun *iso_run) ...@@ -668,7 +672,6 @@ static BracketPair *bidi_compute_bracket_pairs(IsolatedRun *iso_run)
out[pair_count].start = stack_index[j]; out[pair_count].start = stack_index[j];
out[pair_count].end = i; out[pair_count].end = i;
pair_count++; pair_count++;
out = realloc(out, sizeof(BracketPair) * (pair_count+1));
out[pair_count].start = -1; out[pair_count].start = -1;
stack_top = j+1; stack_top = j+1;
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment