Comments (5)
So for example, there is something like
--- rmagick-5.3.0/ext/RMagick/rmimage.c 2023-07-23 21:42:23.000000000 +0900
+++ rmagick-5.4.0/ext/RMagick/rmimage.cpp 2024-02-05 09:32:08.000000000 +0900
@@ -5704,7 +5717,8 @@ Image_dispatch(int argc, VALUE *argv, VA
exception = AcquireExceptionInfo();
GVL_STRUCT_TYPE(ExportImagePixels) args = { image, x, y, columns, rows, map, stg_type, (void *)pixels.v, exception };
- okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ExportImagePixels), &args);
+ void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ExportImagePixels), &args);
+ okay = reinterpret_cast<MagickBooleanType &>(ret);
if (!okay)
{
I think this is incorrect. void *
is 64bit pointer type, MagickBooleanType
is enum, so perhaps int, so 32bit integer size. So once storing 32bit integer size to 64bit pointer size *ret
, then again reading it as 32bit integer as okay
can work with little endian, but this causes to read garbage value on big endian (e.g. s390x).
from rmagick.
I cannot check that because I don't have a big-endian environment. Hmmm...
from rmagick.
A quick workaround: (I've confirmed that the following works)
--- rmagick-5.4.0/ext/RMagick/rmdraw.cpp.orig 2024-02-05 09:32:08.000000000 +0900
+++ rmagick-5.4.0/ext/RMagick/rmdraw.cpp 2024-02-05 13:09:43.296639433 +0900
@@ -1668,7 +1668,7 @@ get_type_metrics(int argc, VALUE *argv,
GVL_STRUCT_TYPE(get_type_metrics) args = { image, draw->info, &metrics };
#endif
void *ret = CALL_FUNC_WITHOUT_GVL(fp, &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
magick_free(draw->info->text);
draw->info->text = NULL;
--- rmagick-5.4.0/ext/RMagick/rmimage.cpp.orig 2024-02-05 09:32:08.000000000 +0900
+++ rmagick-5.4.0/ext/RMagick/rmimage.cpp 2024-02-05 13:09:43.295639434 +0900
@@ -2806,14 +2806,14 @@ Image_clut_channel(int argc, VALUE *argv
BEGIN_CHANNEL_MASK(image, channels);
GVL_STRUCT_TYPE(ClutImage) args = { image, clut, image->interpolate, exception };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ClutImage), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
END_CHANNEL_MASK(image);
CHECK_EXCEPTION();
DestroyExceptionInfo(exception);
#else
GVL_STRUCT_TYPE(ClutImageChannel) args = { image, channels, clut };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ClutImageChannel), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
rm_check_image_exception(image, RetainOnError);
rm_check_image_exception(clut, RetainOnError);
#endif
@@ -4311,13 +4311,13 @@ Image_compress_colormap_bang(VALUE self)
exception = AcquireExceptionInfo();
GVL_STRUCT_TYPE(CompressImageColormap) args = { image, exception };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompressImageColormap), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
CHECK_EXCEPTION();
DestroyExceptionInfo(exception);
#else
GVL_STRUCT_TYPE(CompressImageColormap) args = { image };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompressImageColormap), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
rm_check_image_exception(image, RetainOnError);
#endif
if (!okay)
@@ -5249,7 +5249,7 @@ Image_decipher(VALUE self, VALUE passphr
GVL_STRUCT_TYPE(DecipherImage) args = { new_image, pf, exception };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(DecipherImage), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
rm_check_exception(exception, new_image, DestroyOnError);
if (!okay)
{
@@ -5718,7 +5718,7 @@ Image_dispatch(int argc, VALUE *argv, VA
exception = AcquireExceptionInfo();
GVL_STRUCT_TYPE(ExportImagePixels) args = { image, x, y, columns, rows, map, stg_type, (void *)pixels.v, exception };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ExportImagePixels), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
if (!okay)
{
@@ -6314,7 +6314,7 @@ Image_encipher(VALUE self, VALUE passphr
GVL_STRUCT_TYPE(EncipherImage) args = { new_image, pf, exception };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(EncipherImage), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
rm_check_exception(exception, new_image, DestroyOnError);
if (!okay)
{
@@ -6665,7 +6665,7 @@ Image_export_pixels(int argc, VALUE *arg
GVL_STRUCT_TYPE(ExportImagePixels) args = { image, x_off, y_off, cols, rows, map, QuantumPixel, (void *)pixels, exception };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ExportImagePixels), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
if (!okay)
{
xfree((void *)pixels);
@@ -6858,7 +6858,7 @@ Image_export_pixels_to_str(int argc, VAL
GVL_STRUCT_TYPE(ExportImagePixels) args = { image, x_off, y_off, cols, rows, map, type, (void *)RSTRING_PTR(string), exception };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ExportImagePixels), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
if (!okay)
{
// Let GC have the string buffer.
@@ -7007,7 +7007,7 @@ Image_find_similar_region(int argc, VALU
GVL_STRUCT_TYPE(IsImageSimilar) args = { image, target, &x, &y, exception };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(IsImageSimilar), &args);
#endif
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
CHECK_EXCEPTION();
DestroyExceptionInfo(exception);
@@ -8209,7 +8209,7 @@ Image_import_pixels(int argc, VALUE *arg
GVL_STRUCT_TYPE(ImportImagePixels) args = { image, x_off, y_off, cols, rows, map, stg_type, buffer };
#endif
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ImportImagePixels), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
// Free pixel array before checking for errors.
if (pixels)
@@ -8696,14 +8696,14 @@ Image_level_colors(int argc, VALUE *argv
BEGIN_CHANNEL_MASK(new_image, channels);
GVL_STRUCT_TYPE(LevelImageColors) args = { new_image, &black_color, &white_color, invert, exception };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelImageColors), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
END_CHANNEL_MASK(new_image);
rm_check_exception(exception, new_image, DestroyOnError);
DestroyExceptionInfo(exception);
#else
GVL_STRUCT_TYPE(LevelColorsImageChannel) args = { new_image, channels, &black_color, &white_color, invert };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelColorsImageChannel), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
rm_check_image_exception(new_image, DestroyOnError);
#endif
if (!okay)
@@ -8775,14 +8775,14 @@ Image_levelize_channel(int argc, VALUE *
BEGIN_CHANNEL_MASK(new_image, channels);
GVL_STRUCT_TYPE(LevelizeImage) args = { new_image, black_point, white_point, gamma, exception };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelizeImage), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
END_CHANNEL_MASK(new_image);
rm_check_exception(exception, new_image, DestroyOnError);
DestroyExceptionInfo(exception);
#else
GVL_STRUCT_TYPE(LevelizeImageChannel) args = { new_image, channels, black_point, white_point, gamma };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelizeImageChannel), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
rm_check_image_exception(new_image, DestroyOnError);
#endif
@@ -10202,13 +10202,13 @@ Image_opaque(VALUE self, VALUE target, V
exception = AcquireExceptionInfo();
GVL_STRUCT_TYPE(OpaquePaintImage) args = { new_image, &target_pp, &fill_pp, MagickFalse, exception };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OpaquePaintImage), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
rm_check_exception(exception, new_image, DestroyOnError);
DestroyExceptionInfo(exception);
#else
GVL_STRUCT_TYPE(OpaquePaintImageChannel) args = { new_image, DefaultChannels, &target_pp, &fill_pp, MagickFalse };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OpaquePaintImageChannel), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
rm_check_image_exception(new_image, DestroyOnError);
#endif
@@ -10296,7 +10296,7 @@ Image_opaque_channel(int argc, VALUE *ar
BEGIN_CHANNEL_MASK(new_image, channels);
GVL_STRUCT_TYPE(OpaquePaintImage) args = { new_image, &target_pp, &fill_pp, invert, exception };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OpaquePaintImage), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
END_CHANNEL_MASK(new_image);
new_image->fuzz = keep;
rm_check_exception(exception, new_image, DestroyOnError);
@@ -10304,7 +10304,7 @@ Image_opaque_channel(int argc, VALUE *ar
#else
GVL_STRUCT_TYPE(OpaquePaintImageChannel) args = { new_image, channels, &target_pp, &fill_pp, invert };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OpaquePaintImageChannel), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
new_image->fuzz = keep;
rm_check_image_exception(new_image, DestroyOnError);
@@ -10532,14 +10532,14 @@ Image_paint_transparent(int argc, VALUE
exception = AcquireExceptionInfo();
GVL_STRUCT_TYPE(TransparentPaintImage) args = { new_image, (const MagickPixel *)&color, alpha, invert, exception };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImage), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
new_image->fuzz = keep;
rm_check_exception(exception, new_image, DestroyOnError);
DestroyExceptionInfo(exception);
#else
GVL_STRUCT_TYPE(TransparentPaintImage) args = { new_image, (const MagickPixel *)&color, (Quantum)(QuantumRange - alpha), invert };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImage), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
new_image->fuzz = keep;
// Is it possible for TransparentPaintImage to silently fail?
@@ -10704,7 +10704,7 @@ Image_pixel_color(int argc, VALUE *argv,
#if defined(IMAGEMAGICK_7)
GVL_STRUCT_TYPE(SetImageStorageClass) args = { image, DirectClass, exception };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
CHECK_EXCEPTION();
if (!okay)
{
@@ -10714,7 +10714,7 @@ Image_pixel_color(int argc, VALUE *argv,
#else
GVL_STRUCT_TYPE(SetImageStorageClass) args = { image, DirectClass };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
rm_check_image_exception(image, RetainOnError);
if (!okay)
{
@@ -13925,7 +13925,7 @@ Image_store_pixels(VALUE self, VALUE x_a
exception = AcquireExceptionInfo();
GVL_STRUCT_TYPE(SetImageStorageClass) args = { image, DirectClass, exception };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
CHECK_EXCEPTION();
if (!okay)
{
@@ -13935,7 +13935,7 @@ Image_store_pixels(VALUE self, VALUE x_a
#else
GVL_STRUCT_TYPE(SetImageStorageClass) args = { image, DirectClass };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
rm_check_image_exception(image, RetainOnError);
if (!okay)
{
@@ -14725,13 +14725,13 @@ Image_transparent(int argc, VALUE *argv,
exception = AcquireExceptionInfo();
GVL_STRUCT_TYPE(TransparentPaintImage) args = { new_image, &color, alpha, MagickFalse, exception };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImage), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
rm_check_exception(exception, new_image, DestroyOnError);
DestroyExceptionInfo(exception);
#else
GVL_STRUCT_TYPE(TransparentPaintImage) args = { new_image, &color, (Quantum)(QuantumRange - alpha), MagickFalse };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImage), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
rm_check_image_exception(new_image, DestroyOnError);
#endif
if (!okay)
@@ -14803,13 +14803,13 @@ Image_transparent_chroma(int argc, VALUE
exception = AcquireExceptionInfo();
GVL_STRUCT_TYPE(TransparentPaintImageChroma) args = { new_image, &low, &high, alpha, invert, exception };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImageChroma), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
rm_check_exception(exception, new_image, DestroyOnError);
DestroyExceptionInfo(exception);
#else
GVL_STRUCT_TYPE(TransparentPaintImageChroma) args = { new_image, &low, &high, (Quantum)(QuantumRange - alpha), invert };
void *ret = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImageChroma), &args);
- okay = reinterpret_cast<MagickBooleanType &>(ret);
+ okay = static_cast<MagickBooleanType>(reinterpret_cast<intptr_t &>(ret));
rm_check_image_exception(new_image, DestroyOnError);
#endif
if (!okay)
from rmagick.
@mtasaka Could you send a Pull Request?
from rmagick.
Okay, once created PR.
from rmagick.
Related Issues (20)
- non-conforming drawing primitive definition `roundrectangle' HOT 1
- Threading deadlock between RMagick & Open3 HOT 3
- Can't install RMagick with latest ImageMagick 7 on Windows HOT 3
- Install fails on Ubuntu - solved HOT 1
- rmagick 5.3.0 rspec testsuite fails with ImageMagick 7.1.1-26 (was okay with 7.1.1-15) HOT 1
- An error occurred while running bundle install or gem install rmagick -v '2.16.0' HOT 6
- RMagick install fails on Ruby 3.3.0 in Docker on M1 MacBook Pro HOT 7
- Installation failure after v5.3.0 -> v5.4.1 upgrade on Centos 7 HOT 5
- 'cstdbool' file not found HOT 2
- 2.15.4 Installation Error HOT 4
- Installation fails on macOS with ImageMagick 7 HOT 2
- [MacOS] -Wincompatible-function-pointer-types while trying to install rmagick 3.2.0 on Ruby 2.7.8 HOT 4
- An error occurred while installing rmagick (2.16.0), and Bundler cannot continue. HOT 3
- Change in maintainers? HOT 10
- Installation fails on Windows with latest ImageMagick HOT 4
- Compile error with GCC 14 HOT 3
- ImageMagick detection error on FreeBSD HOT 3
- Unable to install gem against statically-linked ImageMagick HOT 3
- 6.0.1 causes NoDecodeDelegateForThisImageFormat `JPEG' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rmagick.