Fixes segfault on Windows systems

This implicit cast without this check caused a segfault in many targets on Windows when values were just strings.