GetSurrogatePair ignores scanf return value, which means ch may be uninitialised if buf doesn't contain hex or digits (or uses # incorrectly) leading to UTF encoding errors and undefined behaviour.
Here's a patch for the issue
patch-scanf.diff.txt
Compiles in XCode 10 clang on Mac, Visual Studio 2015 on Windows
Tested in production on macOS 10.13, macOS 10.14, Windows 7, Windows 10, Windows Server 2016
Not tested on Linux/gcc
GetSurrogatePairignoresscanfreturn value, which meanschmay be uninitialised ifbufdoesn't contain hex or digits (or uses#incorrectly) leading to UTF encoding errors and undefined behaviour.Here's a patch for the issue
patch-scanf.diff.txt
Compiles in XCode 10 clang on Mac, Visual Studio 2015 on Windows
Tested in production on macOS 10.13, macOS 10.14, Windows 7, Windows 10, Windows Server 2016
Not tested on Linux/gcc