Guard against NULL result

This commit is contained in:
Scott Shawcroft 2022-03-21 10:15:46 -07:00
parent 543940e0a7
commit 92d946fcac
No known key found for this signature in database
GPG Key ID: 0DFD512649C052DA
1 changed files with 15 additions and 0 deletions

View File

@ -27,22 +27,37 @@
#include "shared-bindings/mdns/RemoteService.h"
const char *common_hal_mdns_remoteservice_get_service_type(mdns_remoteservice_obj_t *self) {
if (self->result == NULL) {
return "";
}
return self->result->service_type;
}
const char *common_hal_mdns_remoteservice_get_protocol(mdns_remoteservice_obj_t *self) {
if (self->result == NULL) {
return "";
}
return self->result->proto;
}
const char *common_hal_mdns_remoteservice_get_instance_name(mdns_remoteservice_obj_t *self) {
if (self->result == NULL) {
return "";
}
return self->result->instance_name;
}
const char *common_hal_mdns_remoteservice_get_hostname(mdns_remoteservice_obj_t *self) {
if (self->result == NULL) {
return "";
}
return self->result->hostname;
}
mp_int_t common_hal_mdns_remoteservice_get_port(mdns_remoteservice_obj_t *self) {
if (self->result == NULL) {
return 0;
}
return self->result->port;
}