Skip to content

Commit

Permalink
Add missing close() calls for files
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Lebedev <[email protected]>
  • Loading branch information
lebdron authored and Warchant committed Jul 10, 2018
1 parent 08c58c9 commit 778fa52
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/randombytes/random/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ int randombytes(unsigned char *p, int len) {
while (completed < len) {
ssize_t result = read(source, p + completed, len - completed);
if (result < 0) {
close(source);
return ED25519_ERROR;
}
completed += result;
Expand Down
3 changes: 3 additions & 0 deletions lib/randombytes/urandom/urandom.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ int randombytes(unsigned char *p, int len) {
} else {
ssize_t result = read(source, p, len);
if (result < 0) {
close(source);
return ED25519_ERROR; /* something went wrong */
}
}

close(source);

return ED25519_SUCCESS;
}

0 comments on commit 778fa52

Please sign in to comment.