From 78e159e7365a0ccbbd3b1ec295189da2d0715ab8 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Sat, 28 Sep 2024 14:46:31 +0200 Subject: [PATCH] perl: Return nothing in case invalid data has been passed to libloc 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 Signed-off-by: Michael Tremer --- 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