commit a7cf3076b06abc153debc994e54adfb606bd77f9 from: Stefan Sperling via: Thomas Adam date: Sat Dec 30 18:51:43 2023 UTC do not crash when a meta-data file in the .got directory is empty Reported by Matthias Schmidt ok tb@ commit - 2a2e593352ba687c161d743f54bf5addc8f06d7d commit + a7cf3076b06abc153debc994e54adfb606bd77f9 blob - 5ca8baf35beb64bc05c5d0a9686bfc5324e0258f blob + 7a75e7fcc5708ed78a01f8a89bf3bd3d6b5af636 --- lib/worktree_open.c +++ lib/worktree_open.c @@ -77,6 +77,10 @@ read_meta_file(char **content, const char *path_got, c if (fstat(fd, &sb) != 0) { err = got_error_from_errno2("fstat", path); + goto done; + } + if (sb.st_size == 0) { + err = got_error_path(path, GOT_ERR_WORKTREE_META); goto done; } *content = calloc(1, sb.st_size);