aboutsummaryrefslogtreecommitdiffstats
path: root/bindings
diff options
context:
space:
mode:
Diffstat (limited to 'bindings')
-rw-r--r--bindings/samples/DemoContext.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/bindings/samples/DemoContext.c b/bindings/samples/DemoContext.c
index 66dc6ccf..26677949 100644
--- a/bindings/samples/DemoContext.c
+++ b/bindings/samples/DemoContext.c
@@ -67,6 +67,10 @@ static void myAction (struct afb_req request)
{
MyClientContextT *ctx = (MyClientContextT*) afb_req_context_get(request);
+ if (!ctx) {
+ afb_req_fail(request, "invalid-state", "Can't perform action");
+ return;
+ }
// store something in our plugin private client context
ctx->count++;
afb_req_success_f(request, NULL, "SUCCESS: plugin [%s] Check=[%d]\n", ctx->abcd, ctx->count);
@@ -80,6 +84,10 @@ static void myClose (struct afb_req request)
{
MyClientContextT *ctx = (MyClientContextT*) afb_req_context_get(request);
+ if (!ctx) {
+ afb_req_success(request, NULL, NULL);
+ return;
+ }
// store something in our plugin private client context
ctx->count++;
afb_req_success_f(request, NULL, "SUCCESS: plugin [%s] Close=[%d]\n", ctx->abcd, ctx->count);