[PATCH] Initialize Callbacks structs to 0 for mamasymbolist subscriber


Michael Schonberg <mschonberg@...>
 

From: Mike Schonberg <mschonberg@...>

This avoids a potentional sgmentation fault in the event that an uninitialized
callback gets invoked.

Signed-off-by: John Gray <jgray@...>
---
.../src/examples/c/mamasymbollistsubscriberc.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/mama/c_cpp/src/examples/c/mamasymbollistsubscriberc.c b/mama/c_cpp/src/examples/c/mamasymbollistsubscriberc.c
index 29a2eb7..0160df7 100644
--- a/mama/c_cpp/src/examples/c/mamasymbollistsubscriberc.c
+++ b/mama/c_cpp/src/examples/c/mamasymbollistsubscriberc.c
@@ -151,6 +151,7 @@ int main (int argc, const char **argv)
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 @@ static void subscribeToSymbols (void)
mama_status status = MAMA_STATUS_OK;
size_t i;
mamaMsgCallbacks callbacks;
+ memset(&callbacks, 0, sizeof(callbacks));

callbacks.onCreate = subscriptionOnCreate;
callbacks.onError = subscriptionOnError;
--
1.7.5.4