Skip to content

suspicious UNINITIALIZED READ warning when calling GetKeyNameTextW #1819

@mistmist

Description

@mistmist

Not sure if this is a bug in DrMemory, but i'm getting this surprising warning: according to MSDN the GetKeyNameTextW should write a null terminator at buf[ret] but DrMemory 1.9.0-4 (32-bit) says that there's a UNINITIALIZED READ on the "if (buf[ret])". (The key in the example is "CTRL")

https://msdn.microsoft.com/en-us/library/windows/desktop/ms646300%28v=vs.120%29.aspx

Build the following program with Visual Studio 2013:

cl.exe -Zi foo.cc user32.lib

#include <windows.h>

int main()
{
  WCHAR buf[350];
  int ret = GetKeyNameTextW(35454976, buf, 350);
  if (buf[ret]) // HERE
    return 1;
  else
    return 2;
}

Running it with "drmemory.exe foo.exe" on Windows 7:

Dr. Memory version 1.9.0 build 4 built on Oct  2 2015 13:13:14
Dr. Memory results for pid 4056: "foo.exe"
Application cmdline: "foo.exe"
Recorded 116 suppression(s) from default C:\Users\ms\DrMemory-Windows-1.9.0-4\bin\suppress-default.txt

Error #1: UNINITIALIZED READ: reading register edx
#0 main               [c:\cygwin\tmp\foo.cc:10]
Note: @0:00:01.291 in thread 3764
Note: instruction: test   %edx %edx

Running it with "-light" reports no error.
"-debug -dr_debug -pause_at_assert" does not print anything interesting.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions