Skip to content

Commit

Permalink
Simplified mechanism for null-terminating main buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
solusipse committed Oct 19, 2017
1 parent 288bf2e commit 10129c8
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions fiche.c
Original file line number Diff line number Diff line change
Expand Up @@ -761,12 +761,7 @@ static int save_to_file(const Fiche_Settings *s, uint8_t *data, char *slug) {
}

// Null-terminate buffer if not null terminated already
for (int i = 0; i < s->buffer_len; i++) {
if (data[i] == 0) {
break;
}
data[s->buffer_len - 1] = 0;
}
data[s->buffer_len - 1] = 0;

if ( fprintf(f, "%s", data) < 0 ) {
fclose(f);
Expand Down

0 comments on commit 10129c8

Please sign in to comment.