[PATCH 1.1] mamasymbolist subscriber: Initialize Callbacks structs to 0 for mamasymbolist subscriber


John Gray <jgray@...>
 

This avoids a potential segmentation fault in the event that an uninitialized

callback gets invoked.

 

 

Index: c_cpp/src/examples/c/mamasymbollistsubscriberc.c

===================================================================

RCS file: /cvsroot/products/mama/c_cpp/src/examples/c/Attic/mamasymbollistsubscriberc.c,v

retrieving revision 1.1.2.2

diff -u -r1.1.2.2 mamasymbollistsubscriberc.c

--- c_cpp/src/examples/c/mamasymbollistsubscriberc.c               27 Sep 2011 16:54:39 -0000           1.1.2.2

+++ c_cpp/src/examples/c/mamasymbollistsubscriberc.c            29 Dec 2011 05:26:02 -0000

@@ -151,6 +151,7 @@

     mama_status         status;

     mamaMsgCallbacks    symbolListCallbacks;

     mamaSubscription    symbolListSubscription;

+    memset(&symbolListCallbacks, 0, sizeof(symbolListCallbacks));

     gSymbolList = (const char**) calloc (MAX_SUBSCRIPTIONS, sizeof (char*));

     gSubscriptionList = (mamaSubscription*)calloc (MAX_SUBSCRIPTIONS,

@@ -463,6 +464,7 @@

     mama_status      status  = MAMA_STATUS_OK;

     size_t           i;

     mamaMsgCallbacks callbacks;

+    memset(&callbacks, 0, sizeof(callbacks));

     callbacks.onCreate       = subscriptionOnCreate;

     callbacks.onError        = subscriptionOnError;

 

Signed-off-by: John Gray <jgray@...>

 

Join Openmama-dev@lists.openmama.org to automatically receive all group messages.