Skip to content

Commit

Permalink
FIX: Resolve stack overflow caused by insufficient disk space. (#479)
Browse files Browse the repository at this point in the history
* FIX: Resolve stack overflow caused by insufficient disk space.

* modify the format

* FIX: Resolve stack overflow caused by insufficient disk space.

* modify the format

---------

Co-authored-by: yuencong <yuencong@kuaishou.com>
  • Loading branch information
2 people authored and bamx23 committed May 24, 2024
1 parent b5daf52 commit 62ceadf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Source/KSCrash/Recording/Tools/KSFileUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,14 +475,18 @@ void ksfu_closeBufferedWriter(KSBufferedWriter* writer)

bool ksfu_writeBufferedWriter(KSBufferedWriter* writer, const char* restrict const data, const int length)
{
if(length > writer->bufferLength - writer->position)
{
ksfu_flushBufferedWriter(writer);
}
if(length > writer->bufferLength)
{
return ksfu_writeBytesToFD(writer->fd, data, length);
}
if(length > writer->bufferLength - writer->position)
{
if (!ksfu_flushBufferedWriter(writer))
{
return false;
}
}

memcpy(writer->buffer + writer->position, data, length);
writer->position += length;
return true;
Expand Down

0 comments on commit 62ceadf

Please sign in to comment.