diff --git a/src/unix/linux-core.c b/src/unix/linux-core.c index 333dbe80..2d712483 100644 --- a/src/unix/linux-core.c +++ b/src/unix/linux-core.c @@ -562,7 +562,7 @@ static int uv__cpu_num(FILE* statfile_fp, unsigned int* numcpus) { char buf[1024]; if (!fgets(buf, sizeof(buf), statfile_fp)) - abort(); + return -EIO; num = 0; while (fgets(buf, sizeof(buf), statfile_fp)) { @@ -571,6 +571,9 @@ static int uv__cpu_num(FILE* statfile_fp, unsigned int* numcpus) { num++; } + if (num == 0) + return -EIO; + *numcpus = num; return 0; } @@ -593,9 +596,6 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { if (err < 0) goto out; - assert(numcpus != (unsigned int) -1); - assert(numcpus != 0); - err = -ENOMEM; ci = uv__calloc(numcpus, sizeof(*ci)); if (ci == NULL)