Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ringbuffer.c - improper use of memcpy return value #4

Open
missblit opened this issue Jul 20, 2014 · 0 comments
Open

ringbuffer.c - improper use of memcpy return value #4

missblit opened this issue Jul 20, 2014 · 0 comments

Comments

@missblit
Copy link

In ringbuffer.c, and in exercise 44 of LCTHW, you have a couple instances similar to:

void *result = memcpy(buffer->buffer + buffer->end, data, length);
check(result != NULL, "Failed to write data into buffer.");

However, memcpy merely returns 'dest'. The return value is not indicative of success or failure in any way. Checking it against null is harmless but seems like a bug, and may mislead readers as to how memcpy works.

I was alerted to this issue in the comments section of a recent Hacker News post: https://news.ycombinator.com/item?id=8059283

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant