lib: Fix CID 1034723 Explicit null dereferenced
[sfrench/samba-autobuild/.git] / lib / addns / dnssock.c
index b1d794db45614de3292f11e429dedc531b70e9cf..df17523439731a029b96ee995e7443668525ab29 100644 (file)
@@ -321,13 +321,14 @@ static DNS_ERROR dns_receive_tcp(TALLOC_CTX *mem_ctx,
 
        buf->size = ntohs(len);
 
-       if (buf->size) {
-               if (!(buf->data = talloc_array(buf, uint8_t, buf->size))) {
-                       TALLOC_FREE(buf);
-                       return ERROR_DNS_NO_MEMORY;
-               }
-       } else {
-               buf->data = NULL;
+       if (buf->size == 0) {
+               *presult = buf;
+               return ERROR_DNS_SUCCESS;
+       }
+
+       if (!(buf->data = talloc_array(buf, uint8_t, buf->size))) {
+               TALLOC_FREE(buf);
+               return ERROR_DNS_NO_MEMORY;
        }
 
        err = read_all(conn->s, buf->data, buf->size);