Skip to content
Commit 9528229f authored by Simon Glass's avatar Simon Glass Committed by Tom Rini
Browse files

setexpr: Correct dropping of final unmatched string



At present the 'nlen' variable increases with each loop. If the previous
loop had back references, then subsequent loops without back references
use the wrong value of nlen. The value is larger, meaning that the string
terminator from nbuf is copied along to the main buffer, thus terminating
the string prematurely.

This leads to the final result being truncated, e.g. missing the last
(unmatched) part of the string. So "match match tail" become
"replaced replaced" instead of "replaced replaced tail".

Fix this by resetting nlen to the correct value each time around the lop.

Fixes: 855f18ea ("setexpr: add regex substring matching and substitution")
Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
parent d422c77a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment