Fix potential missing nul character on resolved symbol names

The symbol name returned by SymFromName may not contains a NUL character
when the symbol name is exactly the size of the buffer. It believe this
may also happen when the symbol name is too long and truncated.

The original code is based on:
  https://msdn.microsoft.com/en-us/library/windows/desktop/ms680580(v=vs.85).aspx

A right implementation can be found here:
  https://cs.chromium.org/chromium/src/base/debug/stack_trace_win.cc?l=145&rcl=f4ecb9e37e9e2d59e32b8b96f23ac4a1e33b9552

As described here:
  https://msdn.microsoft.com/en-us/library/windows/desktop/ms680686(v=vs.85).aspx

  NameLen
    The length of the name, in characters, not including the null-terminating character.
  MaxNameLen
    The size of the Name buffer, in characters. If this member is 0, the Name member is not used.

This issue was causing the catapult symbolisation script to encode incorrect (random) characters into the symbol names.
See the example in the bug.

R=wfh@chromium.org, chrisha@chromium.org, erikchen@chromium.org, ajwong@chromium.org
BUG=713741

Review-Url: https://codereview.chromium.org/2832643004
Cr-Commit-Position: refs/heads/master@{#466098}
2 files changed