Skip to content

Commit 242c9b1

Browse files
committed
Add preprocessor conditional to protect mosquitto_userdata()
1 parent 9d9f6ac commit 242c9b1

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

mosquitto_mosq.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,15 +1327,15 @@ switch_status_t mosq_destroy(mosquitto_connection_t *connection)
13271327
return SWITCH_STATUS_GENERR;
13281328
}
13291329

1330-
userdata = mosquitto_userdata(connection->mosq);
1331-
if (!userdata) {
1332-
log(SWITCH_LOG_ERROR, "mosq_destroy() called with NULL userdata pointer\n");
1333-
return SWITCH_STATUS_GENERR;
1334-
}
1335-
1336-
profile = (mosquitto_profile_t *)userdata->profile;
1337-
1338-
log(SWITCH_LOG_DEBUG, "mosq_destroy(): profile %s connection %s\n", profile->name, connection->name);
1330+
#if LIBMOSQUITTO_VERSION_NUMBER >= 1006008
1331+
userdata = mosquitto_userdata(connection->mosq);
1332+
if (!userdata) {
1333+
log(SWITCH_LOG_ERROR, "mosq_destroy() called with NULL userdata pointer\n");
1334+
return SWITCH_STATUS_GENERR;
1335+
}
1336+
profile = (mosquitto_profile_t *)userdata->profile;
1337+
log(SWITCH_LOG_DEBUG, "mosq_destroy(): profile %s connection %s\n", profile->name, connection->name);
1338+
#endif
13391339

13401340
switch_safe_free(connection->userdata);
13411341
mosquitto_destroy(connection->mosq);

0 commit comments

Comments
 (0)