X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=bindings%2Fsamples%2FDemoContext.c;h=a2fec7502f541448ebf4798241470926f1059211;hb=4dc768d67031aa99e2b885a0df7e643fdd1fa80c;hp=66dc6ccf7855d3ff346081ce8ce62bc346be2675;hpb=a38382e89710db2c298f7f101e3ba0cf3681287c;p=src%2Fapp-framework-binder.git diff --git a/bindings/samples/DemoContext.c b/bindings/samples/DemoContext.c index 66dc6ccf..a2fec750 100644 --- a/bindings/samples/DemoContext.c +++ b/bindings/samples/DemoContext.c @@ -19,6 +19,7 @@ #include #include +#define AFB_BINDING_VERSION 1 #include typedef struct { @@ -67,6 +68,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 +85,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);