Skip to content

Commit

Permalink
fix(tform): avoid segfault when TempSortDir is unavailable
Browse files Browse the repository at this point in the history
Avoid null pointer dereferences during early termination before sort
buffer allocation.

Close #605.
  • Loading branch information
tueda committed Jan 24, 2025
1 parent fa83e5f commit 6be6d51
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sources/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1686,6 +1686,9 @@ VOID CleanUp(WORD par)
int i;

if ( FG.fname ) {
#ifdef WITHPTHREADS
if ( B ) {
#endif
CleanUpSort(0);
for ( i = 0; i < 3; i++ ) {
if ( AR.Fscr[i].handle >= 0 ) {
Expand All @@ -1701,6 +1704,9 @@ VOID CleanUp(WORD par)
AR.Fscr[i].POfill = 0;
}
}
#ifdef WITHPTHREADS
}
#endif
if ( par > 0 ) {
/*
Close all input levels above the lowest?
Expand All @@ -1718,12 +1724,18 @@ VOID CleanUp(WORD par)
}
}
CloseFile(AC.StoreHandle);
#ifdef WITHPTHREADS
if ( B )
#endif
if ( par >= 0 || AR.StoreData.Handle < 0 || AM.ClearStore ) {
remove(FG.fname);
}
dontremove:;
#else
CloseFile(AC.StoreHandle);
#ifdef WITHPTHREADS
if ( B )
#endif
if ( par >= 0 || AR.StoreData.Handle < 0 || AM.ClearStore > 0 ) {
remove(FG.fname);
}
Expand Down

0 comments on commit 6be6d51

Please sign in to comment.