about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2022-11-27 09:41:49 +0100
committerptitSeb <sebastien.chev@gmail.com>2022-11-27 09:41:49 +0100
commit3819aecf078fcf47b2bc73713531361406a51895 (patch)
treeb5e343717520e95cbb27647a18be8588c236516a /src
parenta186b22d6e1b0ae92a45dba84d3f67e0248aff89 (diff)
downloadbox64-3819aecf078fcf47b2bc73713531361406a51895.tar.gz
box64-3819aecf078fcf47b2bc73713531361406a51895.zip
Fixed an issue with grabNCpu function, as getline might use realloc, don't use alloca to allocate initial line
Diffstat (limited to 'src')
-rwxr-xr-xsrc/wrapped/wrappedlibc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c
index a0029596..d1d686b1 100755
--- a/src/wrapped/wrappedlibc.c
+++ b/src/wrapped/wrappedlibc.c
@@ -1337,7 +1337,7 @@ void grabNCpu() {
         nCPU = 0;
         int bogo = 0;
         size_t len = 500;
-        char* line = alloca(len);
+        char* line = malloc(len);
         while ((dummy = getline(&line, &len, f)) != -1) {
             if(!strncmp(line, "processor\t", strlen("processor\t")))
                 ++nCPU;
@@ -1350,6 +1350,7 @@ void grabNCpu() {
                 }
             }
         }
+        free(line);
         fclose(f);
         if(!nCPU) nCPU=1;
     }