diff options
author | Kuan-Wei Chiu <visitorckw@gmail.com> | 2024-06-13 00:39:20 +0800 |
---|---|---|
committer | Kuan-Wei Chiu <visitorckw@gmail.com> | 2024-06-13 00:42:12 +0800 |
commit | d45cd63583b0a888d0867fb77f092a811e99b38e (patch) | |
tree | 762f659837f7c74dac56aa9a4f7bbc5ff101e8d2 | |
parent | 0c9b460cc46aebfa4eb6e1fbe928895c0a8fcfbd (diff) | |
download | afl++-d45cd63583b0a888d0867fb77f092a811e99b38e.tar.gz |
Fix memory allocation check in aflpp custom mutators
The memory allocation check in afl_custom_fuzz function was incorrect. The condition was erroneously checking if ptr was non-null, whereas it should return 0 when ptr is null. Correct the condition to properly handle memory allocation failures. Fixes: 32ffa266 ("max_len support")
-rw-r--r-- | custom_mutators/aflpp/aflpp.c | 2 | ||||
-rw-r--r-- | custom_mutators/aflpp/standalone/aflpp-standalone.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/custom_mutators/aflpp/aflpp.c b/custom_mutators/aflpp/aflpp.c index 0b236f76..ea50751a 100644 --- a/custom_mutators/aflpp/aflpp.c +++ b/custom_mutators/aflpp/aflpp.c @@ -48,7 +48,7 @@ size_t afl_custom_fuzz(my_mutator_t *data, uint8_t *buf, size_t buf_size, u8 *ptr = realloc(data->buf, max_size); - if (ptr) { + if (!ptr) { return 0; diff --git a/custom_mutators/aflpp/standalone/aflpp-standalone.c b/custom_mutators/aflpp/standalone/aflpp-standalone.c index 3a2cbc2f..a3789cd1 100644 --- a/custom_mutators/aflpp/standalone/aflpp-standalone.c +++ b/custom_mutators/aflpp/standalone/aflpp-standalone.c @@ -53,7 +53,7 @@ size_t afl_custom_fuzz(my_mutator_t *data, uint8_t *buf, size_t buf_size, u8 *ptr = realloc(data->buf, max_size); - if (ptr) { + if (!ptr) { return 0; |