aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2010-10-05 10:42:58 +0200
committerErlang/OTP <[email protected]>2010-10-05 10:42:58 +0200
commit7501aa3cc1f2ace6dc68c780dd329d23c35a1d50 (patch)
tree2b37945786b2d6ab7c28b54f311f65a666223154
parent9c6842dbbe45bdf1568f165cc135257c4addbe0e (diff)
parent35d4270f1e3d233bd3e0b2b001480c7bf32ff09d (diff)
downloadotp-7501aa3cc1f2ace6dc68c780dd329d23c35a1d50.tar.gz
otp-7501aa3cc1f2ace6dc68c780dd329d23c35a1d50.tar.bz2
otp-7501aa3cc1f2ace6dc68c780dd329d23c35a1d50.zip
Merge branch 'pan/win2003-crash/OTP-8876' into maint-r14
* pan/win2003-crash/OTP-8876: Teach read_topology not to crash on W2K3
-rw-r--r--erts/lib_src/common/erl_misc_utils.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/erts/lib_src/common/erl_misc_utils.c b/erts/lib_src/common/erl_misc_utils.c
index 116c9886d8..498ce6837a 100644
--- a/erts/lib_src/common/erl_misc_utils.c
+++ b/erts/lib_src/common/erl_misc_utils.c
@@ -1228,7 +1228,10 @@ read_topology(erts_cpu_info_t *cpuinfo)
nodes++;
}
- core_id = malloc(sizeof(int)*(packages ? packages : 1));
+ if (!packages) {
+ packages = 1;
+ }
+ core_id = malloc(sizeof(int)*packages);
if (!core_id) {
res = -ENOMEM;
goto error;
@@ -1286,11 +1289,13 @@ read_topology(erts_cpu_info_t *cpuinfo)
* Nodes and packages may not be supported; pretend
* that there are one if this is the case...
*/
- if (!nodes)
- cpuinfo->topology[l].node = 0;
- if (!packages)
- cpuinfo->topology[l].processor = 0;
if (slpip[rix].ProcessorMask & (((ULONG_PTR) 1) << l)) {
+ if (!nodes) {
+ cpuinfo->topology[l].node = 0;
+ }
+ if (!packages) {
+ cpuinfo->topology[l].processor = 0;
+ }
if (processor < 0) {
processor = cpuinfo->topology[l].processor;
if (processor < 0) {