Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/gks/ft.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ static int ft_join_path(ft_path_char_t *result, size_t size, const ft_path_char_
return 0;
}

StringCbPrintfW(result, size, L"%ws%c%ws", first, delim, second);
StringCbPrintfW(result, size * sizeof(wchar_t), L"%ws%c%ws", first, delim, second);
return 1;
#else
const char delim = '/';
Expand Down Expand Up @@ -728,7 +728,7 @@ static ft_path_char_t *gks_ft_get_font_path(const char *font_name, const char *f
StringCbLengthW(prefix, MAXPATHLEN, &len);
len += 2 * (7 + strlen(font_name) + strlen(font_file_extension) + 1);
font_path = (ft_path_char_t *)gks_malloc(len * sizeof(ft_path_char_t));
StringCbPrintfW(font_path, MAXPATHLEN, L"%lS\\FONTS\\%S%S", prefix, font_name, font_file_extension);
StringCbPrintfW(font_path, len * sizeof(ft_path_char_t), L"%lS\\FONTS\\%S%S", prefix, font_name, font_file_extension);
#else
const char *prefix;
char *font_path;
Expand Down
7 changes: 5 additions & 2 deletions lib/gks/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ static void *load_library(const char *name)
handle = LoadLibrary(pathname);
if (handle == NULL)
{
GetEnvironmentVariableW(L"GRDIR", grdir, MAX_PATH);
StringCbPrintfW(w_pathname, MAX_PATH, L"%ws\\bin\\%S.%S", grdir, name, EXTENSION);
if (!GetEnvironmentVariableW(L"GRDIR", grdir, MAX_PATH))
{
MultiByteToWideChar(CP_UTF8, 0, GRDIR, -1, grdir, MAX_PATH);
}
StringCbPrintfW(w_pathname, sizeof(w_pathname), L"%ws\\bin\\%S.%S", grdir, name, EXTENSION);
handle = LoadLibraryExW(w_pathname, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (handle == NULL)
{
Expand Down
6 changes: 3 additions & 3 deletions lib/gks/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static DWORD WINAPI gksqt_thread(LPVOID parm)
STARTUPINFOW startupInfo;
PROCESS_INFORMATION processInformation;

StringCbPrintfW(w_cmd_line, CMD_LINE_LEN, L"cmd.exe /c \"%ls\"", cmd);
StringCbPrintfW(w_cmd_line, sizeof(w_cmd_line), L"cmd.exe /c \"%ls\"", cmd);

if (!GetEnvironmentVariableW(L"WSLENV", buffer, BUFFER_LEN))
{
Expand Down Expand Up @@ -305,11 +305,11 @@ static int open_socket(int wstype)
{
if (!GetEnvironmentVariableW(L"GRDIR", w_env, MAXPATHLEN))
{
StringCbPrintfW(command, CMD_LINE_LEN, L"%S\\bin\\gksqt.exe", GRDIR);
StringCbPrintfW(command, sizeof(command), L"%S\\bin\\gksqt.exe", GRDIR);
}
else
{
StringCbPrintfW(command, CMD_LINE_LEN, L"%ws\\bin\\gksqt.exe", w_env);
StringCbPrintfW(command, sizeof(command), L"%ws\\bin\\gksqt.exe", w_env);
}
}
#else
Expand Down
6 changes: 3 additions & 3 deletions lib/gr/stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ static DWORD WINAPI grplot_thread(LPVOID parm)
STARTUPINFOW startupInfo;
PROCESS_INFORMATION processInformation;

StringCbPrintfW(w_cmd_line, CMD_LINE_LEN, L"cmd /c \"%ls\"", cmd);
StringCbPrintfW(w_cmd_line, sizeof(w_cmd_line), L"cmd /c \"%ls\"", cmd);

ZeroMemory(&startupInfo, sizeof(startupInfo));
startupInfo.cb = sizeof(startupInfo);
Expand Down Expand Up @@ -520,11 +520,11 @@ int gr_startlistener(void)
{
if (!GetEnvironmentVariableW(L"GRDIR", w_env, MAXPATHLEN))
{
StringCbPrintfW(command, CMD_LINE_LEN, L"%S\\bin\\grplot.exe --listen %i", GRDIR, grplot_port);
StringCbPrintfW(command, sizeof(command), L"%S\\bin\\grplot.exe --listen %i", GRDIR, grplot_port);
}
else
{
StringCbPrintfW(command, CMD_LINE_LEN, L"%s\\bin\\grplot.exe --listen %i", w_env, grplot_port);
StringCbPrintfW(command, sizeof(command), L"%s\\bin\\grplot.exe --listen %i", w_env, grplot_port);
}
}
#else
Expand Down