Skip to content

Commit 55ba12c

Browse files
authored
Merge pull request #567 from xry111/xry111/undoc-trunc-again
recover the undocumented feature needed by colord (again). Looks great, thank you
2 parents 4bf926a + 40588c3 commit 55ba12c

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/cmsio0.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,12 @@ cmsBool MemoryWrite(struct _cms_io_handler* iohandler, cmsUInt32Number size, con
214214

215215
if (size == 0) return TRUE; // Write zero bytes is ok, but does nothing
216216

217-
// Check for available space.
217+
// Check for available space. Truncate the output in case the space
218+
// is not enough instead of erroring out. See
219+
// https://github.com/hughsie/colord/issues/147.
218220

219-
if (size > ResData->Size || ResData->Pointer > (ResData->Size - size))
220-
goto WriteError;
221+
if (size > ResData->Size - ResData->Pointer)
222+
size = ResData->Size - ResData->Pointer;
221223

222224
memmove(ResData ->Block + ResData ->Pointer, Ptr, size);
223225
ResData ->Pointer += size;

0 commit comments

Comments
 (0)