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

View File

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