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

reduce message by 20 to make room for context and prevent truncation … #661

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ typedef struct {

/*** error reporting ***/

#define JSON_ERROR_CONTEXT_LENGTH 20
static void error_set(json_error_t *error, const lex_t *lex, enum json_error_code code,
const char *msg, ...) {
va_list ap;
char msg_text[JSON_ERROR_TEXT_LENGTH];
char msg_text[JSON_ERROR_TEXT_LENGTH-JSON_ERROR_CONTEXT_LENGTH];
char msg_with_context[JSON_ERROR_TEXT_LENGTH];

int line = -1, col = -1;
Expand All @@ -96,8 +97,8 @@ static void error_set(json_error_t *error, const lex_t *lex, enum json_error_cod
return;

va_start(ap, msg);
vsnprintf(msg_text, JSON_ERROR_TEXT_LENGTH, msg, ap);
msg_text[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
vsnprintf(msg_text, JSON_ERROR_TEXT_LENGTH-JSON_ERROR_CONTEXT_LENGTH, msg, ap);
msg_text[JSON_ERROR_TEXT_LENGTH - (JSON_ERROR_CONTEXT_LENGTH+1)] = '\0';
va_end(ap);

if (lex) {
Expand Down