diff options
| author | Ingo Bürk | 2019-06-18 09:33:47 +0200 | 
|---|---|---|
| committer | GitHub | 2019-06-18 09:33:47 +0200 | 
| commit | bd7de0c8ff07023f0ccfdc11bd2f0ab930611076 (patch) | |
| tree | b6e35d33b4aec49343a88a046268684b8d697be6 /src | |
| parent | Added function to print content from file (#331) (diff) | |
| parent | print_file_contents: allocate enough to include \0 (diff) | |
Merge pull request #347 from thrasymache/overflow
print_file_contents: allocate enough to include \0
Diffstat (limited to 'src')
| -rw-r--r-- | src/print_file_contents.c | 2 | 
1 files changed, 1 insertions, 1 deletions
| diff --git a/src/print_file_contents.c b/src/print_file_contents.c index afbe3e3..91ad80e 100644 --- a/src/print_file_contents.c +++ b/src/print_file_contents.c @@ -23,7 +23,7 @@ static void *scalloc(size_t size) {  void print_file_contents(yajl_gen json_gen, char *buffer, const char *title, const char *path, const char *format, const char *format_bad, const int max_chars) {      const char *walk = format;      char *outwalk = buffer; -    char *buf = scalloc(max_chars * sizeof(char)); +    char *buf = scalloc(max_chars * sizeof(char) + 1);      int n = -1;      int fd = open(path, O_RDONLY); | 
