[sr-dev] [kamailio/kamailio] nats: make sure pkg & shm memory is allocated; check pointers before freeing memory (#2792)