From afae632ed2811d0bd5c2679417c8b30d70c00a8f Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Thu, 20 May 2021 16:33:28 +0100 Subject: [PATCH] Handles in Carbon are garbage-collected double-pointers, fix their usage. --- setter/src/unix/darwin/carbon.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/setter/src/unix/darwin/carbon.c b/setter/src/unix/darwin/carbon.c index 59d4dd8..1be3d15 100644 --- a/setter/src/unix/darwin/carbon.c +++ b/setter/src/unix/darwin/carbon.c @@ -219,7 +219,9 @@ int CarbonResourceFork(const char* path) if(h) { - memcpy(h, IcnsResource, ICNS_RESOURCE_SIZE); + HLock(h); + memcpy(*h, IcnsResource, ICNS_RESOURCE_SIZE); + HUnlock(h); AddResource(h, rtIcons, -16455, IcnsResourceNamePascal); WriteResource(h); ReleaseResource(h); @@ -276,7 +278,9 @@ int CarbonResourceFork(const char* path) if(h) { - memcpy(h, PictResource, PICT_RESOURCE_SIZE); + HLock(h); + memcpy(*h, PictResource, PICT_RESOURCE_SIZE); + HUnlock(h); AddResource(h, ftPICTFile, 29876, PictResourceNamePascal); WriteResource(h); ReleaseResource(h); @@ -333,7 +337,9 @@ int CarbonResourceFork(const char* path) if(h) { - memcpy(h, VersResource, VERS_RESOURCE_SIZE); + HLock(h); + memcpy(*h, VersResource, VERS_RESOURCE_SIZE); + HUnlock(h); AddResource(h, rtVersion, 1, VersResourceNamePascal); WriteResource(h); ReleaseResource(h); @@ -390,7 +396,9 @@ int CarbonResourceFork(const char* path) if(h) { - memcpy(h, IcnsResource, ICNS_RESOURCE_SIZE); + HLock(h); + memcpy(*h, IcnsResource, ICNS_RESOURCE_SIZE); + HUnlock(h); AddResource(h, rtIcons, -16455, IcnsResourceNamePascal); WriteResource(h); ReleaseResource(h); @@ -402,7 +410,9 @@ int CarbonResourceFork(const char* path) if(h) { - memcpy(h, PictResource, PICT_RESOURCE_SIZE); + HLock(h); + memcpy(*h, PictResource, PICT_RESOURCE_SIZE); + HUnlock(h); AddResource(h, ftPICTFile, -16455, PictResourceNamePascal); WriteResource(h); ReleaseResource(h); @@ -414,7 +424,9 @@ int CarbonResourceFork(const char* path) if(h) { - memcpy(h, VersResource, VERS_RESOURCE_SIZE); + HLock(h); + memcpy(*h, VersResource, VERS_RESOURCE_SIZE); + HUnlock(h); AddResource(h, rtVersion, 1, VersResourceNamePascal); WriteResource(h); ReleaseResource(h);