From be75ca4de56bfcdf00864f884b010d0ea02725c9 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 17 Jul 2025 11:10:41 -0700 Subject: [PATCH] Fix linked list iteration when displaying errors When a script has problem with the magic comment encoding, we only display that error. However, if there are other syntax errors in the file, the error linked list could contain multiple items. This lead to an inconsistency in the "size" field of the linked list, and the actual items in the linked list. In other words, the linked list had more than one item, but the size field was one. The error display routine would only allocate `size` items, but iterating the linked list would overrun the array. This commit changes the iterator to compare the current node to the "finish" node in the linked list, no longer assuming the linked list ends with NULL. [Bug #21461] --- prism_compile.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/prism_compile.c b/prism_compile.c index e9585805243ffa..ded330f3cb5b2d 100644 --- a/prism_compile.c +++ b/prism_compile.c @@ -10613,7 +10613,9 @@ pm_parse_errors_format_sort(const pm_parser_t *parser, const pm_list_t *error_li if (errors == NULL) return NULL; int32_t start_line = parser->start_line; - for (pm_diagnostic_t *error = (pm_diagnostic_t *) error_list->head; error != NULL; error = (pm_diagnostic_t *) error->node.next) { + pm_diagnostic_t *finish = (pm_diagnostic_t * )error_list->tail->next; + + for (pm_diagnostic_t *error = (pm_diagnostic_t *) error_list->head; error != finish; error = (pm_diagnostic_t *) error->node.next) { pm_line_column_t start = pm_newline_list_line_column(newline_list, error->location.start, start_line); pm_line_column_t end = pm_newline_list_line_column(newline_list, error->location.end, start_line); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy