Skip to content

Commit 644ef85

Browse files
authored
Add nullptr validation on GeoDB class (#675)
1 parent 4cff199 commit 644ef85

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/GeoDB.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ MaxmindDB::~MaxmindDB()
5252
City MaxmindDB::getGeoLoc(const struct sockaddr *sa) const
5353
{
5454

55-
if (!_enabled) {
55+
if (!_enabled || sa == nullptr) {
5656
return {};
5757
}
5858

@@ -69,7 +69,7 @@ City MaxmindDB::getGeoLoc(const struct sockaddr *sa) const
6969
City MaxmindDB::getGeoLoc(const struct sockaddr_in *sa4) const
7070
{
7171

72-
if (!_enabled) {
72+
if (!_enabled || sa4 == nullptr) {
7373
return {};
7474
}
7575

@@ -106,7 +106,7 @@ City MaxmindDB::getGeoLoc(const struct sockaddr_in *sa4) const
106106
City MaxmindDB::getGeoLoc(const struct sockaddr_in6 *sa6) const
107107
{
108108

109-
if (!_enabled) {
109+
if (!_enabled || sa6 == nullptr) {
110110
return {};
111111
}
112112

@@ -143,7 +143,7 @@ City MaxmindDB::getGeoLoc(const struct sockaddr_in6 *sa6) const
143143
City MaxmindDB::getGeoLoc(const char *ip_address) const
144144
{
145145

146-
if (!_enabled) {
146+
if (!_enabled || ip_address == nullptr) {
147147
return {};
148148
}
149149

@@ -262,7 +262,7 @@ std::string MaxmindDB::getASNString(const struct sockaddr *sa) const
262262
std::string MaxmindDB::getASNString(const struct sockaddr_in *sa4) const
263263
{
264264

265-
if (!_enabled) {
265+
if (!_enabled || sa4 == nullptr) {
266266
return {};
267267
}
268268
std::string ip_address;
@@ -298,7 +298,7 @@ std::string MaxmindDB::getASNString(const struct sockaddr_in *sa4) const
298298
std::string MaxmindDB::getASNString(const struct sockaddr_in6 *sa6) const
299299
{
300300

301-
if (!_enabled) {
301+
if (!_enabled || sa6 == nullptr) {
302302
return {};
303303
}
304304

@@ -335,7 +335,7 @@ std::string MaxmindDB::getASNString(const struct sockaddr_in6 *sa6) const
335335
std::string MaxmindDB::getASNString(const char *ip_address) const
336336
{
337337

338-
if (!_enabled) {
338+
if (!_enabled || ip_address == nullptr) {
339339
return {};
340340
}
341341

0 commit comments

Comments
 (0)