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

v1: save: Avoid call to sign pad before checking data read error #243

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/save.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,16 +639,18 @@ static cyaml_err_t cyaml__write_int(
{
cyaml_err_t err;
int64_t number;
uint64_t raw;

number = cyaml_sign_pad(
cyaml_data_read(schema->data_size, data, &err),
schema->data_size);
if (err == CYAML_OK) {
const char *string = cyaml__get_int(number);
err = cyaml__emit_scalar(ctx, schema, string, YAML_INT_TAG);
raw = cyaml_data_read(schema->data_size, data, &err);
if (err != CYAML_OK) {
return err;
}

return err;
number = cyaml_sign_pad(raw, schema->data_size);

return cyaml__emit_scalar(ctx, schema,
cyaml__get_int(number),
YAML_INT_TAG);
}

/**
Expand Down
Loading