Skip to content

Commit

Permalink
... part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
henkmet committed Jun 23, 2024
1 parent e545961 commit 8be5f21
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions dwmbar.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ char *read_file_content(const char *path) {
return smprintf("Even wachten");
}

char *buffer = malloc(length + 1);
char *buffer = malloc(length);
if (!buffer) {
fclose(f);
perror("malloc");
exit(1);
}

fread(buffer, 1, length-1, f);
buffer[length] = '\0';
size_t newLen = fread(buffer, 1, length-1, f);
buffer[newLen++] = '\0';
fclose(f);

return buffer;
Expand Down

0 comments on commit 8be5f21

Please sign in to comment.