Skip to content

Commit

Permalink
Merge pull request #243 from tlsa/tlsa/v1-save-int-write-cleanup
Browse files Browse the repository at this point in the history
v1: save: Avoid call to sign pad before checking data read error
  • Loading branch information
tlsa authored Aug 26, 2024
2 parents 087750d + 1d19dc4 commit 67ac0db
Showing 1 changed file with 9 additions and 7 deletions.
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

0 comments on commit 67ac0db

Please sign in to comment.