aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ffi/ffi_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/ffi/ffi_util.h')
-rw-r--r--src/lib/ffi/ffi_util.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/ffi/ffi_util.h b/src/lib/ffi/ffi_util.h
index 2962b05e1..e77a2debb 100644
--- a/src/lib/ffi/ffi_util.h
+++ b/src/lib/ffi/ffi_util.h
@@ -82,7 +82,11 @@ int apply_fn(botan_struct<T, M>* o, const char* func_name, F func)
if(o->magic_ok() == false)
return BOTAN_FFI_ERROR_INVALID_OBJECT;
- return ffi_guard_thunk(func_name, [&]() { return func(*o->unsafe_get()); });
+ T* p = o->unsafe_get();
+ if(p == nullptr)
+ return BOTAN_FFI_ERROR_INVALID_OBJECT;
+
+ return ffi_guard_thunk(func_name, [&]() { return func(*p); });
}
#define BOTAN_FFI_DO(T, obj, param, block) \