Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Files: .gitignore
Copyright: None
License: CC0-1.0

# project (tooling/config)
Files: .project
Copyright: None
License: CC0-1.0

# xml toml json conf yaml sh
Files: *.toml *.json *conf *.yaml *.sh
Copyright: None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,15 @@ bool CFX_FileBufferArchive::Flush() {
}

bool CFX_FileBufferArchive::WriteBlock(const void* pBuf, size_t size) {
// A zero-length write is a valid no-op. Some callers may pass nullptr when
// size==0 (e.g. empty name/string serialization). Treat it as success to
// avoid aborting on benign inputs.
if (size == 0)
return true;

ASSERT(pBuf);
ASSERT(size > 0);
if (!pBuf)
return false;

const uint8_t* buffer = reinterpret_cast<const uint8_t*>(pBuf);
size_t temp_size = size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ bool CPDF_Stream::WriteTo(IFX_ArchiveStream* archive,
if (!archive->WriteString("stream\r\n"))
return false;

if (size && !archive->WriteBlock(data.data(), size))
if (!archive->WriteBlock(data.data(), size))
return false;

if (!archive->WriteString("\r\nendstream"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,14 @@ size_t CFX_MemoryStream::ReadBlock(void* buffer, size_t size) {
bool CFX_MemoryStream::WriteBlockAtOffset(const void* buffer,
FX_FILESIZE offset,
size_t size) {
if (!buffer || offset < 0 || !size)
if (offset < 0)
return false;

if (size == 0)
return true;

DCHECK(buffer);
if (!buffer)
return false;

FX_SAFE_SIZE_T safe_new_pos = size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ struct FxFolderHandleCloser {

class IFX_WriteStream {
public:
// When `size` is 0, treat it as a no-op and return true. That is also the
// only time when `pData` can be null.
virtual bool WriteBlock(const void* pData, size_t size) = 0;
virtual bool WriteString(ByteStringView str) = 0;

Expand Down
Loading