Skip to content

Commit

Permalink
ClipboardExtendedPlugin:
Browse files Browse the repository at this point in the history
Make sure the ioAddClipboardData fails on macos if setData:forType: fails
and/or raises an exception.  Avoid crashing the VM if setData:forType:
raises an exception.

Fix a bug in the scanline width calculation for importing bitmaps on
Windows for depths below 8.
  • Loading branch information
eliotmiranda committed Mar 21, 2023
1 parent a44a013 commit 0dd0229
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Expand Up @@ -82,7 +82,15 @@
NSArray *arrayOfTypes = @[formatType];

[inPasteboard declareTypes: arrayOfTypes owner: nil];
[inPasteboard setData: data forType: formatType];
int ok = true;
@try {
ok = [inPasteboard setData: data forType: formatType];
}
@catch (NSException *exception) {
ok = false;
}
if (!ok)
interpreterProxy->primitiveFailFor(PrimErrOperationFailed);
}

void
Expand All @@ -105,7 +113,7 @@
sqInt dataLength = [dataBuffer length];
sqInt outData = interpreterProxy->instantiateClassindexableSize(interpreterProxy->classByteArray(), dataLength);
char *outDataPtr = (char *) interpreterProxy->firstIndexableField(outData);
[dataBuffer getBytes: outDataPtr];
[dataBuffer getBytes: outDataPtr length: dataLength];

return outData;
}
Expand Down
Expand Up @@ -329,7 +329,7 @@ sqPasteboardCopyItemFlavorDataformat(CLIPBOARDTYPE inPasteboard, sqInt format)
if ((format == CF_DIB || format == CF_DIBV5)
&& pdib->biHeight > 0) {
unsigned char *dest = interpreterProxy->firstIndexableField(outData);
long scanLineLength = pdib->biWidth * pdib->biBitCount / 8;
long scanLineLength = ((pdib->biWidth * pdib->biBitCount + 31) / 32) * 4;
unsigned char *source, *start;
assert(pdib->biSizeImage + sizeof(*pdib) < dataSize);
pdib->biHeight = - pdib->biHeight;
Expand Down

0 comments on commit 0dd0229

Please sign in to comment.