bugfix for potential segfault
recent gcc found a pointer dereference error that could cause a segfault (though the pointer is only used in read operation). This release fixes that and also adds headers to elimiate 'implicit declaration' warnings. SPDX headers added.