Add a helper function to check if a pointer is pointing to a valid buffer before using it in an expression.
Use it in
Tested: Tested with the fuzzer test that reporter provided with all the crash data. All the heap related issues gone.
Signed-off-by: Dawn Han firstname.lastname@example.org