Skip to content

Duplicated output when calling recode_perform_task with an output stream and previously buffered output #67

@oreo639

Description

@oreo639

This affects enca 1.19 when data is passed through stdin when linked with librecode 3.7.15. (This issue doesn't happen when enca is linked against 3.6 librecode)

https://github.com/nijel/enca/blob/6fc4a2a3e9ec16b892e325f6f53b2501fbcacb17/src/convert_recode.c#L145-L201

When librecode is built against libiconv and enca -VVVVV -L cs -C librecode -x UTF-8 <test-recode.actual >test-recode.tmp is run with the following input, the output to test-recode.tmp is duplicated: https://github.com/nijel/enca/blob/6fc4a2a3e9ec16b892e325f6f53b2501fbcacb17/test/cs-s.iso88592

When performing the two calls individually, the first call outputs the correct conversion once, the second call outputs nothing, however when run in sucession, the first call outputs the correct string and the second call results in it being duplicated, this is despite recode_put_bytes()/recode_put_byte() never getting called for the second conversion. (stepping through it with gdb, it enters transform_ucs2_utf8(), gets the first byte which is EOF and exits, which is correct)

This duplication doesn't seem to happen with glibc's iconv, where the recode_transform_with_iconv() codepath is taken instead.

For whatever reason, calling fflush(stdout); between the two calls appears to stop the duplication.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions