-#if wxUSE_UNICODE
- strcpy( buf, wxConvFile.cWC2MB( path ) );
-#else
- strcpy( buf, path.c_str() );
-#endif
- int fdTemp = mkstemp( buf );
+ // we need to copy the path to the buffer in which mkstemp() can modify it
+ wxCharBuffer buf = wxConvFile.cWX2MB( path );
+
+ // cast is safe because the string length doesn't change
+ int fdTemp = mkstemp( (char*)(const char*) buf );