AmendHub

Download:

vkoskiv

/

MacNTP

/

amendments

/

6

Hack ntp_req_free() to not crash and use it

I have no idea why xfree() crashes the program when I'm freeing
xalloc'd pointers. I'll just put in stack buffers in there instead.

vkoskiv made amendment 6 about 1 year ago
--- main.c Tue Aug 22 19:57:28 2023 +++ main.c Tue Aug 22 20:45:17 2023 @@ -69,8 +69,9 @@ void ntp_req_free(void *reqptr) { if (req == NULL) return; _UDPRelease(&req->udp_iopb, req->udp_stream, nil, nil, false); - xfree(req->udp_buf); - xfree(reqptr); + //FIXME: These crash the program, no idea why + //if (req->udp_buf != NULL) xfree(req->udp_buf); + //xfree(ptr); } #define HOST_URL "time.google.com"; @@ -219,8 +220,6 @@ int main(int argc, char **argv) { dump_ntp_packet(&req->payload); error: - _UDPRelease(&req->udp_iopb, req->udp_stream, nil, nil, false); - //ntp_req_free(req); - //xfree(req); + ntp_req_free(&req); return 0; }