# HG changeset patch # User Daniele Nicolodi # Date 1365430544 -7200 # Node ID 8b90fbba59effcdcc0777c005c4290bdb95f47fd # Parent 62b4f0b7a6e7add3695a17de461206648e93242f Fix buffer size in SendMessage macro diff -r 62b4f0b7a6e7 -r 8b90fbba59ef data-provider.h --- a/data-provider.h Tue Mar 26 18:23:46 2013 +0100 +++ b/data-provider.h Mon Apr 08 16:15:44 2013 +0200 @@ -19,14 +19,16 @@ }; /* message buffer */ -static char messages[256][16]; +#define DATA_PROVIDER_MSGLEN 256 +#define DATA_PROVIDER_MSGNUM 16 +static char messages[DATA_PROVIDER_MSGLEN][DATA_PROVIDER_MSGNUM]; static unsigned int messageid = 0; -#define SendMessage(threadId, ...) \ - do { \ - char *message = messages[messageid++ % 16]; \ - snprintf(message, sizeof(message), ##__VA_ARGS__); \ - PostDeferredCallToThread(MessageCB, message, threadId); \ +#define SendMessage(threadId, ...) \ + do { \ + char *message = messages[messageid++ % DATA_PROVIDER_MSGNUM]; \ + snprintf(message, DATA_PROVIDER_MSGLEN - 1, ##__VA_ARGS__); \ + PostDeferredCallToThread(MessageCB, message, threadId); \ } while (0) #endif