Fixes: 316964709e21286c2af5 "util: add os_read_file() helper"
Reported-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
if (actually_read > 0)
offset += actually_read;
+ /* Final resize to actual size */
+ len = offset + 1;
+ char *newbuf = realloc(buf, len);
+ if (!newbuf) {
+ free(buf);
+ close(fd);
+ errno = -ENOMEM;
+ return NULL;
+ }
+ buf = newbuf;
+
buf[offset] = '\0';
return buf;