mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
Fix possible segfault
This commit is contained in:
@@ -26,6 +26,12 @@ void ffDetectOSImpl(FFOSResult* os, const FFinstance* instance)
|
||||
ffStrbufInit(&os->buildID);
|
||||
ffSettingsGetAndroidProperty("ro.build.id", &os->buildID);
|
||||
|
||||
ffStrbufInit(&os->systemName);
|
||||
ffStrbufSetS(&os->systemName, instance->state.utsname.sysname);
|
||||
|
||||
ffStrbufInit(&os->architecture);
|
||||
ffStrbufSetS(&os->architecture, instance->state.utsname.machine);
|
||||
|
||||
ffStrbufInitA(&os->idLike, 0);
|
||||
ffStrbufInitA(&os->variant, 0);
|
||||
ffStrbufInitA(&os->variantID, 0);
|
||||
|
||||
@@ -128,7 +128,6 @@ static void detectOS(FFOSResult* os, const FFinstance* instance)
|
||||
|
||||
void ffDetectOSImpl(FFOSResult* os, const FFinstance* instance)
|
||||
{
|
||||
ffStrbufInit(&os->systemName);
|
||||
ffStrbufInit(&os->name);
|
||||
ffStrbufInit(&os->prettyName);
|
||||
ffStrbufInit(&os->id);
|
||||
@@ -139,6 +138,7 @@ void ffDetectOSImpl(FFOSResult* os, const FFinstance* instance)
|
||||
ffStrbufInit(&os->versionID);
|
||||
ffStrbufInit(&os->codename);
|
||||
ffStrbufInit(&os->buildID);
|
||||
ffStrbufInit(&os->systemName);
|
||||
ffStrbufInit(&os->architecture);
|
||||
|
||||
ffStrbufSetS(&os->systemName, instance->state.utsname.sysname);
|
||||
|
||||
+3
-5
@@ -13,13 +13,11 @@ static void buildOutputDefault(const FFOSResult* os, FFstrbuf* result)
|
||||
if(os->name.length > 0)
|
||||
ffStrbufAppend(result, &os->name);
|
||||
else if(os->prettyName.length > 0)
|
||||
ffStrbufAppend(result, &os->name);
|
||||
ffStrbufAppend(result, &os->prettyName);
|
||||
else if(os->id.length > 0)
|
||||
ffStrbufAppend(result, &os->id);
|
||||
else if(os->systemName.length > 0)
|
||||
ffStrbufAppend(result, &os->systemName);
|
||||
else
|
||||
ffStrbufAppendS(result, "Linux");
|
||||
ffStrbufAppend(result, &os->systemName);
|
||||
|
||||
//Append version if it is missing
|
||||
if(os->versionID.length > 0 && ffStrbufFirstIndex(result, &os->versionID) == result->length)
|
||||
@@ -84,7 +82,7 @@ void ffPrintOS(FFinstance* instance)
|
||||
{
|
||||
const FFOSResult* os = ffDetectOS(instance);
|
||||
|
||||
if(os->name.length == 0 && os->prettyName.length == 0)
|
||||
if(os->name.length == 0 && os->prettyName.length == 0 && os->id.length == 0 && os->systemName.length == 0)
|
||||
{
|
||||
ffPrintError(instance, FF_OS_MODULE_NAME, 0, &instance->config.os, "Could not detect OS");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user