AmendHub

Download:

jcs

/

subtext

/

amendments

/

292

bile: Fix file closing in bile_open error path

The bile object may not have been created yet, so don't dereference
it, and its refnum may not be set either so FSClose(fh) instead.

jcs made amendment 292 about 1 year ago
--- bile.c Fri Sep 16 17:24:26 2022 +++ bile.c Tue Nov 29 17:13:48 2022 @@ -193,8 +193,7 @@ bile_open(const Str255 filename, short vrefnum) return bile; open_bail: - FSClose(bile->frefnum); - bile->frefnum = -1; + FSClose(fh); if (bile != NULL) xfree(&bile); return NULL; @@ -222,13 +221,14 @@ bile_open_recover_map(const Str255 filename, short vre if (bile) { bile->map_ptr = bile->old_map_ptr; bile_write_map(bile); + bile_flush(bile, true); } return bile; } short -bile_flush(struct bile *bile, short and_vol) +bile_flush(struct bile *bile, bool and_vol) { IOParam pb; short ret;