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

Remove assert if json is too big for jsonencoder #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nikobockerman
Copy link
Collaborator

No description provided.

@nikobockerman nikobockerman requested review from exg and rauhma July 13, 2020 12:15
@nikobockerman nikobockerman force-pushed the remove-assert-if-json-size-is-too-large branch from 0e60cee to ac02a84 Compare July 13, 2020 12:39
src/jsonop.c Outdated

jsonop_t *jsonop_make_request(async_t *async, http_client_t *client,
const char *uri, json_thing_t *request_body)
{
http_op_t *http_op = http_client_make_request(client, "POST", uri);
if (!http_op)
return NULL;
jsonencoder_t *encoder = json_encode(async, request_body);
ssize_t size = jsonencoder_size(encoder);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behaviour of this assignment is implementation-defined (C standard 6.3.1.3). I suggest

size_t size = jsonencoder_size(encoder);
if (size > SSIZE_MAX) {
...
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Changed accordingly.

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

Successfully merging this pull request may close these issues.

2 participants