Update to ldns-1.6.7
[dragonfly.git] / contrib / ldns / buffer.c
index c6259b4..5a6b0ba 100644 (file)
@@ -44,9 +44,13 @@ ldns_buffer_new_frm_data(ldns_buffer *buffer, void *data, size_t size)
 
        buffer->_position = 0; 
        buffer->_limit = buffer->_capacity = size;
+       buffer->_fixed = 0;
        buffer->_data = LDNS_XMALLOC(uint8_t, size);
+       if(!buffer->_data) {
+               buffer->_status = LDNS_STATUS_MEM_ERR;
+               return;
+       }
        memcpy(buffer->_data, data, size);
-       buffer->_fixed = 0;
        buffer->_status = LDNS_STATUS_OK;
        
        ldns_buffer_invariant(buffer);