Fix netd crash on gethostbyname(NULL) and add a regression test

Bug: 169105756
Change-Id: I923d28d5bb83c3db0927dffffd3063e3add6a91a
diff --git a/gethnamaddr.cpp b/gethnamaddr.cpp
index 23f94bb..6a5f116 100644
--- a/gethnamaddr.cpp
+++ b/gethnamaddr.cpp
@@ -388,8 +388,11 @@
 int resolv_gethostbyname(const char* name, int af, hostent* hp, char* buf, size_t buflen,
                          const android_net_context* netcontext, hostent** result,
                          NetworkDnsEventReported* event) {
-    getnamaddr info;
+    if (name == nullptr || hp == nullptr) {
+        return EAI_SYSTEM;
+    }
 
+    getnamaddr info;
     ResState res;
     res_init(&res, netcontext, event);