Fix memory errors

- `swaylock` does not free the password buffer on ENTER
 - read_line: OOB write when a line in /proc/modules contains a
   terminating character at `size` position.
This commit is contained in:
Dan Robertson 2018-02-11 03:55:45 +00:00 committed by Dan Robertson
parent 7c3b0ffc32
commit 397592adf1
No known key found for this signature in database
GPG key ID: 45C4A652C47E42A5
2 changed files with 2 additions and 1 deletions

View file

@ -36,7 +36,7 @@ char *read_line(FILE *file) {
}
string[length++] = c;
}
if (length + 1 == size) {
if (length + 1 >= size) {
char *new_string = realloc(string, length + 1);
if (!new_string) {
free(string);