What if the call to GetEnvVar fails? and chrome is allocated on the stack and there's no zero to be taken as end-of-string? Simplest way to test: char chrome[256] = {}; also, test return value of GetEnvironmentVariable [0=failed, sizeof(chrome)=not enough space, # = bytes written].