From fdae3a8861abb10d5f0640123a7845f9cdbcba7b Mon Sep 17 00:00:00 2001 From: hanjinpeng Date: Thu, 17 Sep 2026 02:33:05 -0400 Subject: [PATCH] task.c: make recode_get_bytes read from the input buffer When the input is a memory buffer, recode_get_bytes copied bytes from the subtask's *output* buffer, and advanced the output cursor, instead of reading the input text. With an empty output it returned no data at all; otherwise it returned (and consumed) output bytes. recode(1) only calls it for file input, but it is declared in recodext.h for externally written steps. Read from the input buffer. --- src/task.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/task.c b/src/task.c index 749d956..39de6eb 100644 --- a/src/task.c +++ b/src/task.c @@ -60,10 +60,10 @@ recode_get_bytes (RECODE_SUBTASK subtask, char *data, size_t n) return fread (data, 1, n, subtask->input.file); else { - size_t bytes_left = subtask->output.limit - subtask->output.cursor; + size_t bytes_left = subtask->input.limit - subtask->input.cursor; size_t bytes_to_copy = MIN (n, bytes_left); - memcpy (data, subtask->output.cursor, bytes_to_copy); - subtask->output.cursor += bytes_to_copy; + memcpy (data, subtask->input.cursor, bytes_to_copy); + subtask->input.cursor += bytes_to_copy; return bytes_to_copy; } }