On Tue, 24 Nov 2020 07:44:14 +0200 Tzvetomir Stoyanov <tz.stoyanov@xxxxxxxxx> wrote: > > index 326b455..690506c 100644 > > --- a/tracefs-utils.c > > +++ b/tracefs-utils.c > > @@ -220,7 +220,7 @@ __hidden int str_read_file(const char *file, char **buffer) > > } while (r > 0); > > > > close(fd); > > - if (r == 0 && size > 0) { > > + if (r == 0) { > > buf[size] = '\0'; > > If size is 0, in case of an empty file, then buf should also be NULL > and this assignment > will be on invalid memory. I quickly realized that, and sent out a v2 ;-) https://lore.kernel.org/r/20201123154607.5e43e1ff@xxxxxxxxxxxxxxxxxx -- Steve > > > *buffer = buf; > > } else > > --