diff --git a/src/MQTTAsync.c b/src/MQTTAsync.c index 571db0e2..b49f1580 100644 --- a/src/MQTTAsync.c +++ b/src/MQTTAsync.c @@ -340,7 +340,7 @@ int MQTTAsync_createWithOptions(MQTTAsync* handle, const char* serverURI, const } } - if (options->maxBufferedMessages <= 0) + if (options && options->maxBufferedMessages <= 0) { rc = MQTTASYNC_MAX_BUFFERED; goto exit; diff --git a/test/test95.c b/test/test95.c index 8d0b2144..b759790c 100644 --- a/test/test95.c +++ b/test/test95.c @@ -1656,7 +1656,7 @@ int test5(struct Options options) } createOptions.sendWhileDisconnected = 0; - createOptions.maxBufferedMessages = 0; + createOptions.maxBufferedMessages = 1; createOptions.MQTTVersion = MQTTVERSION_5; rc = MQTTAsync_createWithOptions(&d, options.connection, clientidd, MQTTCLIENT_PERSISTENCE_DEFAULT, NULL, &createOptions); @@ -1826,7 +1826,7 @@ int test6(struct Options options) } createOptions.sendWhileDisconnected = 0; - createOptions.maxBufferedMessages = 0; + createOptions.maxBufferedMessages = 1; createOptions.MQTTVersion = MQTTVERSION_5; rc = MQTTAsync_createWithOptions(&d, options.connection, clientidd, MQTTCLIENT_PERSISTENCE_DEFAULT, NULL, &createOptions);