lib: make a copy of state_data, since pointer can be re-used

make a copy of state_data, since pointer can be re-used and the comparison checks
can still give false positives

Signed-off-by: kanna <kanna@cumulusnetworks.com>
lib: don't check for NULL before free