mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Windows: fix potential memory curruption bug in unicode.c
Also add ffStrbufInitWS
This commit is contained in:
@@ -10,6 +10,7 @@ Bugfixes:
|
||||
* Fix iTerm being detected as iTermServer-* sometimes
|
||||
* Fix sound device volume being incorrectly detected as muted sometimes (Sound)
|
||||
* Fix memleaks reported by LeakSanitizer (Linux)
|
||||
* Fix potential memory curruption bug in unicode.c (Windows)
|
||||
|
||||
Logo:
|
||||
* Update Windows 11 ASCII logo to look more visually consistent (#445)
|
||||
|
||||
@@ -17,20 +17,17 @@ void ffStrbufSetNWS(FFstrbuf* result, uint32_t length, const wchar_t* source)
|
||||
result->chars[size_needed] = '\0';
|
||||
}
|
||||
|
||||
FFstrbuf ffStrbufCreateNWS(uint32_t length, const wchar_t* source)
|
||||
void ffStrbufInitNWS(FFstrbuf* result, uint32_t length, const wchar_t* source)
|
||||
{
|
||||
FFstrbuf result;
|
||||
|
||||
if(length == 0)
|
||||
ffStrbufInit(&result);
|
||||
else
|
||||
if(!length)
|
||||
{
|
||||
int size_needed = WideCharToMultiByte(CP_UTF8, 0, source, (int)length, NULL, 0, NULL, NULL);
|
||||
ffStrbufInitA(&result, (uint32_t)size_needed);
|
||||
WideCharToMultiByte(CP_UTF8, 0, source, (int)length, result.chars, size_needed, NULL, NULL);
|
||||
result.length = (uint32_t)size_needed;
|
||||
result.chars[size_needed] = '\0';
|
||||
ffStrbufInit(result);
|
||||
return;
|
||||
}
|
||||
|
||||
return result;
|
||||
int size_needed = WideCharToMultiByte(CP_UTF8, 0, source, (int)length, NULL, 0, NULL, NULL);
|
||||
ffStrbufInitA(result, (uint32_t)size_needed + 1);
|
||||
WideCharToMultiByte(CP_UTF8, 0, source, (int)length, result->chars, size_needed, NULL, NULL);
|
||||
result->length = (uint32_t)size_needed;
|
||||
result->chars[size_needed] = '\0';
|
||||
}
|
||||
|
||||
@@ -13,7 +13,19 @@ static inline void ffStrbufSetWS(FFstrbuf* result, const wchar_t* source)
|
||||
return ffStrbufSetNWS(result, (uint32_t)wcslen(source), source);
|
||||
}
|
||||
|
||||
FFstrbuf ffStrbufCreateNWS(uint32_t length, const wchar_t* source);
|
||||
void ffStrbufInitNWS(FFstrbuf* result, uint32_t length, const wchar_t* source);
|
||||
|
||||
static inline void ffStrbufInitWS(FFstrbuf* result, const wchar_t* source)
|
||||
{
|
||||
return ffStrbufInitNWS(result, (uint32_t)wcslen(source), source);
|
||||
}
|
||||
|
||||
static inline FFstrbuf ffStrbufCreateNWS(uint32_t length, const wchar_t* source)
|
||||
{
|
||||
FFstrbuf result;
|
||||
ffStrbufInitNWS(&result, length, source);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline FFstrbuf ffStrbufCreateWS(const wchar_t* source)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user