mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add comments for string truncation
This commit is contained in:
parent
8a05c606e4
commit
a088f91541
4 changed files with 6 additions and 0 deletions
|
|
@ -62,6 +62,7 @@ namespace Flow.Launcher.Plugin.SharedCommands
|
|||
return string.Empty;
|
||||
}
|
||||
|
||||
// Truncate the buffer to the actual length of the string
|
||||
int validLength = Array.IndexOf(buffer, '\0');
|
||||
if (validLength < 0) validLength = capacity;
|
||||
return new string(buffer, 0, validLength);
|
||||
|
|
|
|||
|
|
@ -61,6 +61,8 @@ public class WindowsInteropHelper
|
|||
fixed (char* pBuffer = buffer)
|
||||
{
|
||||
PInvoke.GetClassName(hWnd, pBuffer, capacity);
|
||||
|
||||
// Truncate the buffer to the actual length of the string
|
||||
int validLength = Array.IndexOf(buffer, '\0');
|
||||
if (validLength < 0) validLength = capacity;
|
||||
windowClass = new string(buffer, 0, validLength);
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@ namespace Flow.Launcher.Plugin.ProcessKiller
|
|||
return string.Empty;
|
||||
}
|
||||
|
||||
// Truncate the buffer to the actual length of the string
|
||||
int validLength = Array.IndexOf(buffer, '\0');
|
||||
if (validLength < 0) validLength = (int)capacity;
|
||||
return new string(buffer, 0, validLength);
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ namespace Flow.Launcher.Plugin.Program.Programs
|
|||
fixed (char* bufferChar = buffer)
|
||||
{
|
||||
((IShellLinkW)link).GetPath((PWSTR)bufferChar, MAX_PATH, &data, (uint)SLGP_FLAGS.SLGP_SHORTPATH);
|
||||
|
||||
// Truncate the buffer to the actual length of the string
|
||||
int validLength = Array.IndexOf(buffer, '\0');
|
||||
if (validLength < 0) validLength = MAX_PATH;
|
||||
target = new string(buffer, 0, validLength);
|
||||
|
|
|
|||
Loading…
Reference in a new issue