Skip to content

Commit d970d9f

Browse files
committed
Use MCAutoStringRefAsLPWSTR where mutable buffer may be required
Some Win32 APIs take a `LPWSTR` rather than a `LPCWSTR` argument. Ensure that if (for some reason) they try to mutate the buffer that they're passed, it doesn't affect the original LiveCode string.
1 parent 553aeb7 commit d970d9f

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

engine/src/dskw32.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2821,7 +2821,7 @@ struct MCWindowsDesktop: public MCSystemInterface, public MCWindowsSystemService
28212821
// SN-2014-06-16 [[ Bug 12648 ]] Shell command does not accept spaces despite being quoted (Windows)
28222822
// Fix for 7
28232823
/* UNCHECKED */ MCStringFormat(t_cmd, "%@ /C \"%@\"", MCshellcmd, p_command);
2824-
MCAutoStringRefAsWString t_wcmd;
2824+
MCAutoStringRefAsLPWSTR t_wcmd;
28252825
t_wcmd . Lock(t_cmd);
28262826
MCU_realloc((char **)&MCprocesses, MCnprocesses,
28272827
MCnprocesses + 1, sizeof(Streamnode));
@@ -3092,7 +3092,7 @@ struct MCWindowsDesktop: public MCSystemInterface, public MCWindowsSystemService
30923092
siStartInfo.hStdOutput = hChildStdoutWr;
30933093
siStartInfo.hStdError = hChildStderrWr;
30943094

3095-
MCAutoStringRefAsWString t_cmdline_wstr;
3095+
MCAutoStringRefAsLPWSTR t_cmdline_wstr;
30963096
/* UNCHECKED */ t_cmdline_wstr.Lock(*t_cmdline);
30973097

30983098
if (CreateProcessW(NULL, *t_cmdline_wstr, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &siStartInfo, &piProcInfo))

engine/src/w32printer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static HANDLE Win32OpenPrinter(MCStringRef p_name)
138138
t_defaults . pDevMode = NULL;
139139
t_defaults . DesiredAccess = PRINTER_ACCESS_USE;
140140

141-
MCAutoStringRefAsWString t_name_wstr;
141+
MCAutoStringRefAsLPWSTR t_name_wstr;
142142
/* UNCHECKED */ t_name_wstr.Lock(p_name);
143143

144144
if (OpenPrinterW(*t_name_wstr, &t_printer, &t_defaults) == 0)

engine/src/w32relaunch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ bool relaunch_startup(MCStringRef p_stack_name)
450450
{
451451
for(unsigned int t_instance = 0; t_instance < t_existing_instance_count; ++t_instance)
452452
{
453-
MCAutoStringRefAsWString t_cmdline_wstr;
453+
MCAutoStringRefAsLPWSTR t_cmdline_wstr;
454454
/* UNCHECKED */ t_cmdline_wstr.Lock(MCcmdline);
455455

456456
message_t t_message;

0 commit comments

Comments
 (0)