* [PATCH] perl: Return nothing in case invalid data has been passed to libloc
@ 2024-09-28 12:46 Stefan Schantl
0 siblings, 0 replies; only message in thread
From: Stefan Schantl @ 2024-09-28 12:46 UTC (permalink / raw)
To: location
[-- Attachment #1: Type: text/plain, Size: 1663 bytes --]
The old croach approch instantly will stop the script if invalid data
will be passed to libloc and also will fail to proper execute the
testsuite.
Signed-off-by: Stefan Schantl <stefan.schantl(a)ipfire.org>
---
src/perl/Location.xs | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/src/perl/Location.xs b/src/perl/Location.xs
index be6df14..896cbcb 100644
--- a/src/perl/Location.xs
+++ b/src/perl/Location.xs
@@ -173,7 +173,7 @@ lookup_country_code(db, address)
// Lookup network
int err = loc_database_lookup_from_string(db, address, &network);
if (err) {
- croak("Error fetching a network from the database\n");
+ goto END;
}
// Extract the country code if we have found a network
@@ -184,6 +184,8 @@ lookup_country_code(db, address)
loc_network_unref(network);
}
+
+ END:
OUTPUT:
RETVAL
@@ -213,7 +215,7 @@ lookup_network_has_flag(db, address, flag)
// Lookup network
int err = loc_database_lookup_from_string(db, address, &network);
if (err) {
- croak("Error fetching a network from the database\n");
+ goto END;
}
// Check if the network has the given flag
@@ -225,6 +227,7 @@ lookup_network_has_flag(db, address, flag)
loc_network_unref(network);
}
+ END:
OUTPUT:
RETVAL
@@ -240,7 +243,7 @@ lookup_asn(db, address)
// Lookup network
int err = loc_database_lookup_from_string(db, address, &network);
if (err) {
- croak("Error fetching a network from the database\n");
+ goto END;
}
// Extract the ASN
@@ -252,6 +255,8 @@ lookup_asn(db, address)
loc_network_unref(network);
}
+
+ END:
OUTPUT:
RETVAL
--
2.39.5
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-09-28 12:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-28 12:46 [PATCH] perl: Return nothing in case invalid data has been passed to libloc Stefan Schantl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox