Skip to content

iconvstrImpl() reads errno after Riconv_close(), which can change it #19755

Description

@kevinushey

Summary

When Riconv() fails with an error that iconvstrImpl() in src/cpp/r/RUtil.cpp doesn't handle (anything other than a substitutable EILSEQ/EINVAL or a resumable E2BIG), it calls Riconv_close(handle) and then builds the error from R_ERRNO. Closing the handle can change errno, so the reported error may describe the close rather than the failed conversion.

Fix

Save R_ERRNO right after Riconv() fails, before calling Riconv_close(), and build the error from the saved value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions