mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Sysctl: returns error on failed string fetch and removes malloc null check
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -47,10 +47,12 @@ const char* ffSysctlGetString(const char* propName, FFstrbuf* result) {
|
||||
|
||||
ffStrbufEnsureFree(result, (uint32_t) neededLength - 1);
|
||||
|
||||
if (sysctlbyname(propName, result->chars + result->length, &neededLength, NULL, 0) == 0) {
|
||||
result->length += (uint32_t) neededLength - 1;
|
||||
if (sysctlbyname(propName, result->chars + result->length, &neededLength, NULL, 0) != 0) {
|
||||
return "sysctlbyname() failed to retrieve string data";
|
||||
}
|
||||
|
||||
result->length += (uint32_t) neededLength - 1;
|
||||
|
||||
result->chars[result->length] = '\0';
|
||||
|
||||
return NULL;
|
||||
@@ -81,9 +83,6 @@ void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength) {
|
||||
}
|
||||
|
||||
void* data = malloc(*resultLength);
|
||||
if (data == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (sysctl(request, requestLength, data, resultLength, NULL, 0) != 0) {
|
||||
free(data);
|
||||
|
||||
Reference in New Issue
Block a user