diff options
author | Björn-Egil Dahlberg <[email protected]> | 2013-07-11 18:39:04 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2013-07-15 17:01:36 +0200 |
commit | 5e768c8765bc70d70599dd9a6e5d27875de490e3 (patch) | |
tree | 3e24d30d87e50b8d508b40856ab54d482ac9910b /erts/emulator | |
parent | 5576be6a5a874dbeb2b12014b5834542756e72b3 (diff) | |
download | otp-5e768c8765bc70d70599dd9a6e5d27875de490e3.tar.gz otp-5e768c8765bc70d70599dd9a6e5d27875de490e3.tar.bz2 otp-5e768c8765bc70d70599dd9a6e5d27875de490e3.zip |
Fix erlang:system_info(compile_info)
Allocation needs to be in correct order.
Diffstat (limited to 'erts/emulator')
-rwxr-xr-x | erts/emulator/beam/erl_bif_info.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/erts/emulator/beam/erl_bif_info.c b/erts/emulator/beam/erl_bif_info.c index a43eee6420..673dfc658c 100755 --- a/erts/emulator/beam/erl_bif_info.c +++ b/erts/emulator/beam/erl_bif_info.c @@ -2612,24 +2612,29 @@ BIF_RETTYPE system_info_1(BIF_ALIST_1) } #endif else if (ERTS_IS_ATOM_STR("compile_info",BIF_ARG_1)) { - Eterm *hp = HAlloc(BIF_P, 3*3+3*2); /* three two tuples + - three list elems */ - Eterm res = NIL; - Eterm *lhp = HAlloc(BIF_P, 2*(strlen(erts_build_flags_CONFIG_H)+ - strlen(erts_build_flags_CFLAGS)+ - strlen(erts_build_flags_LDFLAGS))); - - res = CONS(hp+9,TUPLE2(hp, am_config_h, - buf_to_intlist(&lhp, erts_build_flags_CONFIG_H, - strlen(erts_build_flags_CONFIG_H), NIL)),res); - res = CONS(hp+11,TUPLE2(hp+3, am_cflags, - buf_to_intlist(&lhp, erts_build_flags_CFLAGS, - strlen(erts_build_flags_CFLAGS), NIL)),res); - res = CONS(hp+13,TUPLE2(hp+6, am_ldflags, - buf_to_intlist(&lhp, erts_build_flags_LDFLAGS, - strlen(erts_build_flags_LDFLAGS), NIL)),res); - - BIF_RET(res); + Uint sz; + Eterm res = NIL, tup, text; + Eterm *hp = HAlloc(BIF_P, 3*(2 + 3) + /* three 2-tuples and three cons */ + 2*(strlen(erts_build_flags_CONFIG_H) + + strlen(erts_build_flags_CFLAGS) + + strlen(erts_build_flags_LDFLAGS))); + + sz = strlen(erts_build_flags_CONFIG_H); + text = buf_to_intlist(&hp, erts_build_flags_CONFIG_H, sz, NIL); + tup = TUPLE2(hp, am_config_h, text); hp += 3; + res = CONS(hp, tup, res); hp += 2; + + sz = strlen(erts_build_flags_CFLAGS); + text = buf_to_intlist(&hp, erts_build_flags_CFLAGS, sz, NIL); + tup = TUPLE2(hp, am_cflags, text); hp += 3; + res = CONS(hp, tup, res); hp += 2; + + sz = strlen(erts_build_flags_LDFLAGS); + text = buf_to_intlist(&hp, erts_build_flags_LDFLAGS, sz, NIL); + tup = TUPLE2(hp, am_ldflags, text); hp += 3; + res = CONS(hp, tup, res); hp += 2; + + BIF_RET(res); } BIF_ERROR(BIF_P, BADARG); |