]> git.ipfire.org Git - people/ms/libloc.git/blobdiff - src/python/database.c
Correctly handle invalid IP addresses
[people/ms/libloc.git] / src / python / database.c
index d41da47e52813c23ecbb94da3d27bae998f3c6d6..89d578022db7dd4974904afc497515cbf271a1a9 100644 (file)
@@ -138,6 +138,11 @@ static PyObject* Database_lookup(DatabaseObject* self, PyObject* args) {
        // Nothing found
        } else if (r == 1) {
                Py_RETURN_NONE;
+
+       // Invalid input
+       } else if (r == -EINVAL) {
+               PyErr_Format(PyExc_ValueError, "Invalid IP address: %s", address);
+               return NULL;
        }
 
        // Unexpected error