mirror of
https://github.com/json-c/json-c.git
synced 2026-04-05 05:19:07 +08:00
Merge pull request #744 from Kizuna-Meraki/close-random
Close file on error path.
This commit is contained in:
@@ -237,13 +237,15 @@ static int get_dev_random_seed(int *seed)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ssize_t nread = read(fd, seed, sizeof(*seed));
|
ssize_t nread = read(fd, seed, sizeof(*seed));
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
|
||||||
if (nread != sizeof(*seed))
|
if (nread != sizeof(*seed))
|
||||||
{
|
{
|
||||||
fprintf(stderr, "error short read %s: %s", dev_random_file, strerror(errno));
|
fprintf(stderr, "error short read %s: %s", dev_random_file, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user