
+ #define CHECK_NULL(ptr) if (!ptr) return AVERROR(EINVAL)

int av_hwframe_ctx_init(AVBufferRef *ref)
{
+    CHECK_NULL(ref);
     AVHWFramesContext *ctx = (AVHWFramesContext*)ref->data;
     // ... rest of the function
