winpty icon indicating copy to clipboard operation
winpty copied to clipboard

translateException can throw std::bad_alloc

Open rprichard opened this issue 6 years ago • 1 comments

This call to utf8FromWide from translateException can throw std::bad_alloc:

    trace("libwinpty error: code=%u msg='%s'",
        static_cast<unsigned>(ret->code),
        utf8FromWide(winpty_error_msg(ret)).c_str());

Maybe I originally used a %ls in the printf format string, but the narrow byte encoding isn't UTF-8, which is what the DebugClient/trace system uses.

rprichard avatar Jul 17 '17 21:07 rprichard

Two possible fixes:

  • https://github.com/rprichard/winpty/commit/93d1237ac2abedcf042ce01fb13f26a6c31616cd

  • https://github.com/rprichard/winpty/commit/3338e421c209c4d59335d0b81796223b7910cb7c

I think I prefer the latter. They both compile, and winpty runs, but the fix isn't really tested.

rprichard avatar Jul 17 '17 21:07 rprichard