returns 0 if MALLOC_PERTURB_ is unset, or if set to 0, because 0 is not useful
| 35 | |
| 36 | // returns 0 if MALLOC_PERTURB_ is unset, or if set to 0, because 0 is not useful |
| 37 | uint8_t check_malloc_perturb() |
| 38 | { |
| 39 | const size_t TEST_DATA_LEN = 5000; // >1 4kb page |
| 40 | std::unique_ptr<uint8_t[]> test_data{new uint8_t[TEST_DATA_LEN]}; |
| 41 | |
| 42 | uint8_t expected_perturb = test_data[0]; |
| 43 | if (getenv("MALLOC_PERTURB_")) |
| 44 | expected_perturb = 0xff ^ static_cast<uint8_t>(atoi(getenv("MALLOC_PERTURB_"))); |
| 45 | |
| 46 | for (size_t i = 0; i < TEST_DATA_LEN; i++) |
| 47 | if (expected_perturb != test_data[i]) |
| 48 | return 0; |
| 49 | |
| 50 | return expected_perturb; |
| 51 | } |
| 52 | |
| 53 | static command_result command(color_ostream & out, std::vector<std::string> & parameters) |
| 54 | { |