cinera.c: Fix stack-use-after-return segfault
The ClashResolver, or a memory_book variable therein, triggered a stack-use-after-return segfault. Fixed by initialising the ClashResolver in main() and passing it to InitClashResolver() by pointer, rather than initialising it in InitClashResolver().
This commit is contained in:
parent
213bb2f882
commit
14dafa4abe
|
@ -23,7 +23,7 @@ typedef struct
|
|||
version CINERA_APP_VERSION = {
|
||||
.Major = 0,
|
||||
.Minor = 10,
|
||||
.Patch = 29
|
||||
.Patch = 30
|
||||
};
|
||||
|
||||
#define __USE_XOPEN2K8 // NOTE(matt): O_NOFOLLOW
|
||||
|
@ -903,8 +903,8 @@ FreeBook(memory_book *M)
|
|||
void
|
||||
FreeAndReinitialiseBook(memory_book *M)
|
||||
{
|
||||
int PageSize = M->PageSize;
|
||||
int DataWidthInBytes = M->DataWidthInBytes;
|
||||
uint64_t PageSize = M->PageSize;
|
||||
uint64_t DataWidthInBytes = M->DataWidthInBytes;
|
||||
|
||||
FreeBook(M);
|
||||
|
||||
|
@ -4783,18 +4783,16 @@ typedef struct
|
|||
bool Resolving;
|
||||
} clash_resolver;
|
||||
|
||||
clash_resolver
|
||||
InitClashResolver(void)
|
||||
void
|
||||
InitClashResolver(clash_resolver *ClashResolver)
|
||||
{
|
||||
clash_resolver Result = {};
|
||||
Result.Book[0] = InitBook(sizeof(clash_entry), 8);
|
||||
Result.Book[1] = InitBook(sizeof(clash_entry), 8);
|
||||
Result.Main = &Result.Book[0];
|
||||
Result.Holder = &Result.Book[1];
|
||||
Result.Chain = InitBookOfPointers(8);
|
||||
Result.ChainStructure = CS_OPEN_ENDED;
|
||||
Result.Resolving = FALSE;
|
||||
return Result;
|
||||
ClashResolver->Book[0] = InitBook(sizeof(clash_entry), 8);
|
||||
ClashResolver->Book[1] = InitBook(sizeof(clash_entry), 8);
|
||||
ClashResolver->Main = &ClashResolver->Book[0];
|
||||
ClashResolver->Holder = &ClashResolver->Book[1];
|
||||
ClashResolver->Chain = InitBookOfPointers(8);
|
||||
ClashResolver->ChainStructure = CS_OPEN_ENDED;
|
||||
ClashResolver->Resolving = FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -18325,7 +18323,8 @@ main(int ArgC, char **Args)
|
|||
CollationBuffers.Search.ID = BID_COLLATION_BUFFERS_SEARCH; // NOTE(matt): Allocated by SearchToBuffer()
|
||||
|
||||
memory_book TokensList = InitBook(sizeof(tokens), 8);
|
||||
clash_resolver ClashResolver = InitClashResolver();
|
||||
clash_resolver ClashResolver = {};
|
||||
InitClashResolver(&ClashResolver);
|
||||
template BespokeTemplate = {};
|
||||
neighbourhood Neighbourhood = {};
|
||||
|
||||
|
|
Loading…
Reference in New Issue