-- v3: dwrite: Handle memory allocation failure in bidi_compute_bracket_pairs (cppcheck).
From: Alex Henrie alexhenrie24@gmail.com
--- dlls/dwrite/bidi.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/dlls/dwrite/bidi.c b/dlls/dwrite/bidi.c index 142c82f19d0..796f276e2e9 100644 --- a/dlls/dwrite/bidi.c +++ b/dlls/dwrite/bidi.c @@ -632,23 +632,27 @@ static BracketPair *bidi_compute_bracket_pairs(IsolatedRun *iso_run) WCHAR *open_stack; int *stack_index; int stack_top = iso_run->length; - BracketPair *out = NULL; + BracketPair *out; int pair_count = 0; int i;
open_stack = malloc(sizeof(WCHAR) * 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++) { unsigned short ubv = get_table_entry_16(bidi_bracket_table, iso_run->item[i].ch); if (ubv) { - if (!out) - { - out = malloc(sizeof(BracketPair)); - out[0].start = -1; - } - if ((ubv >> 8) == 0) { stack_top--; 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) out[pair_count].start = stack_index[j]; out[pair_count].end = i; pair_count++; - out = realloc(out, sizeof(BracketPair) * (pair_count+1)); out[pair_count].start = -1; stack_top = j+1; break;
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=127729
Your paranoid android.
=== debian11 (32 bit report) ===
user32: win.c:11680: Test failed: 00490138: expected prev 04C30102, got 00000000 win.c:11694: Test failed: hwnd should NOT be topmost win.c:11640: Test failed: 1: hwnd 00490138 is still topmost
This merge request was approved by Nikolay Sivov.