mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2025-02-20 11:43:27 +08:00
FFstrbuf: don't free string literals
This commit is contained in:
parent
5498b0b042
commit
484264027c
@ -549,6 +549,8 @@ uint16_t ffStrbufToUInt16(const FFstrbuf* strbuf, uint16_t defaultValue)
|
||||
|
||||
void ffStrbufDestroy(FFstrbuf* strbuf)
|
||||
{
|
||||
if(strbuf->allocated == 0) return;
|
||||
|
||||
//Avoid free-after-use. These 3 assignments are cheap so don't remove them
|
||||
strbuf->allocated = strbuf->length = 0;
|
||||
free(strbuf->chars);
|
||||
|
@ -24,6 +24,10 @@ int main(int argc, char** argv)
|
||||
|
||||
FFstrbuf strbuf;
|
||||
|
||||
//destroy 0
|
||||
ffStrbufInitA(&strbuf, 0);
|
||||
ffStrbufDestroy(&strbuf);
|
||||
|
||||
//initA
|
||||
|
||||
ffStrbufInitA(&strbuf, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user