regress: Support NULL fdset arguments to select
[adns] / regress / hcommon.c
index ebbef94..301fb2f 100644 (file)
@@ -167,6 +167,10 @@ void Tvbbytes(const void *buf, int len) {
 void Tvbfdset(int max, const fd_set *fds) {
   int i;
   const char *comma= "";
+  if (!fds) {
+    Tvba("null");
+    return;
+  }
   Tvba("[");
   for (i=0; i<max; i++) {
     if (!FD_ISSET(i,fds)) continue;
@@ -281,7 +285,7 @@ void *Hrealloc(void *op, size_t nsz) {
   size_t osz;
   if (op) { oldnode= (void*)((char*)op - MALLOCHSZ); osz= oldnode->sz; } else { osz= 0; }
   np= Hmalloc(nsz);
-  memcpy(np,op, osz>nsz ? nsz : osz);
+  if (osz) memcpy(np,op, osz>nsz ? nsz : osz);
   Hfree(op);
   return np;
 }