rmagick 2.14.0 → 2.15.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rmagick might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.rubocop.yml +79 -45
- data/CODE_OF_CONDUCT.md +13 -0
- data/CONTRIBUTING.md +21 -3
- data/ChangeLog +6 -1
- data/Rakefile +6 -3
- data/ext/RMagick/extconf.rb +2 -1
- data/ext/RMagick/rmagick.c +11 -4
- data/ext/RMagick/rmagick.h +4 -0
- data/ext/RMagick/rmdraw.c +35 -11
- data/ext/RMagick/rmenum.c +13 -4
- data/ext/RMagick/rmfill.c +4 -1
- data/ext/RMagick/rmilist.c +44 -13
- data/ext/RMagick/rmimage.c +196 -59
- data/ext/RMagick/rminfo.c +33 -10
- data/ext/RMagick/rmmain.c +10 -3
- data/ext/RMagick/rmmontage.c +12 -4
- data/ext/RMagick/rmpixel.c +18 -5
- data/ext/RMagick/rmstruct.c +108 -31
- data/ext/RMagick/rmutil.c +48 -24
- data/lib/rmagick/version.rb +1 -1
- data/lib/rmagick_internal.rb +8 -5
- data/rmagick.gemspec +4 -3
- data/spec/rmagick/draw_spec.rb +156 -0
- data/spec/spec_helper.rb +1 -0
- data/test/Magick.rb +0 -1
- data/test/test_all_basic.rb +0 -1
- metadata +25 -7
- data/test/Draw.rb +0 -119
data/ext/RMagick/rmagick.h
CHANGED
@@ -139,6 +139,10 @@
|
|
139
139
|
#define RARRAY_PTR(a) RARRAY((a))->ptr /**< Ruby array pointer */
|
140
140
|
#endif
|
141
141
|
|
142
|
+
// Backport this macro to 1.8.6
|
143
|
+
#if !defined(RB_GC_GUARD)
|
144
|
+
#define RB_GC_GUARD(x) (x)
|
145
|
+
#endif
|
142
146
|
|
143
147
|
//! Convert a C string to a Ruby symbol. Used in marshal_dump/marshal_load methods
|
144
148
|
#define CSTR2SYM(s) ID2SYM(rb_intern(s))
|
data/ext/RMagick/rmdraw.c
CHANGED
@@ -497,7 +497,7 @@ Draw_interword_spacing_eq(VALUE self, VALUE spacing)
|
|
497
497
|
static VALUE
|
498
498
|
image_to_str(Image *image)
|
499
499
|
{
|
500
|
-
|
500
|
+
VALUE dimg = Qnil;
|
501
501
|
unsigned char *blob;
|
502
502
|
size_t length;
|
503
503
|
Info *info;
|
@@ -515,6 +515,8 @@ image_to_str(Image *image)
|
|
515
515
|
magick_free((void*)blob);
|
516
516
|
}
|
517
517
|
|
518
|
+
RB_GC_GUARD(dimg);
|
519
|
+
|
518
520
|
return dimg;
|
519
521
|
}
|
520
522
|
|
@@ -664,7 +666,7 @@ Draw_marshal_load(VALUE self, VALUE ddraw)
|
|
664
666
|
{
|
665
667
|
Draw *draw;
|
666
668
|
Pixel *pixel;
|
667
|
-
|
669
|
+
VALUE val;
|
668
670
|
|
669
671
|
Data_Get_Struct(self, Draw, draw);
|
670
672
|
|
@@ -725,6 +727,8 @@ Draw_marshal_load(VALUE self, VALUE ddraw)
|
|
725
727
|
|
726
728
|
draw->primitives = rb_hash_aref(ddraw, CSTR2SYM("primitives"));
|
727
729
|
|
730
|
+
RB_GC_GUARD(val);
|
731
|
+
|
728
732
|
return self;
|
729
733
|
}
|
730
734
|
|
@@ -1051,7 +1055,7 @@ VALUE Draw_annotate(
|
|
1051
1055
|
VALUE
|
1052
1056
|
Draw_clone(VALUE self)
|
1053
1057
|
{
|
1054
|
-
|
1058
|
+
VALUE clone;
|
1055
1059
|
|
1056
1060
|
clone = Draw_dup(self);
|
1057
1061
|
if (OBJ_FROZEN(self))
|
@@ -1059,6 +1063,8 @@ Draw_clone(VALUE self)
|
|
1059
1063
|
OBJ_FREEZE(clone);
|
1060
1064
|
}
|
1061
1065
|
|
1066
|
+
RB_GC_GUARD(clone);
|
1067
|
+
|
1062
1068
|
return clone;
|
1063
1069
|
}
|
1064
1070
|
|
@@ -1087,7 +1093,7 @@ Draw_composite(int argc, VALUE *argv, VALUE self)
|
|
1087
1093
|
const char *op = "Over";
|
1088
1094
|
double x, y, width, height;
|
1089
1095
|
CompositeOperator cop = OverCompositeOp;
|
1090
|
-
|
1096
|
+
VALUE image;
|
1091
1097
|
Image *comp_img;
|
1092
1098
|
struct TmpFile_Name *tmpfile_name;
|
1093
1099
|
char name[MaxTextExtent];
|
@@ -1339,6 +1345,8 @@ Draw_composite(int argc, VALUE *argv, VALUE self)
|
|
1339
1345
|
// Send "primitive" to self.
|
1340
1346
|
(void) rb_funcall(self, rb_intern("primitive"), 1, rb_str_new2(primitive));
|
1341
1347
|
|
1348
|
+
RB_GC_GUARD(image);
|
1349
|
+
|
1342
1350
|
return self;
|
1343
1351
|
}
|
1344
1352
|
|
@@ -1399,7 +1407,7 @@ VALUE
|
|
1399
1407
|
Draw_dup(VALUE self)
|
1400
1408
|
{
|
1401
1409
|
Draw *draw;
|
1402
|
-
|
1410
|
+
VALUE dup;
|
1403
1411
|
|
1404
1412
|
draw = ALLOC(Draw);
|
1405
1413
|
memset(draw, 0, sizeof(Draw));
|
@@ -1408,6 +1416,9 @@ Draw_dup(VALUE self)
|
|
1408
1416
|
{
|
1409
1417
|
(void)rb_obj_taint(dup);
|
1410
1418
|
}
|
1419
|
+
|
1420
|
+
RB_GC_GUARD(dup);
|
1421
|
+
|
1411
1422
|
return rb_funcall(dup, rm_ID_initialize_copy, 1, self);
|
1412
1423
|
}
|
1413
1424
|
|
@@ -1513,7 +1524,7 @@ VALUE
|
|
1513
1524
|
Draw_initialize(VALUE self)
|
1514
1525
|
{
|
1515
1526
|
Draw *draw, *draw_options;
|
1516
|
-
|
1527
|
+
VALUE options;
|
1517
1528
|
|
1518
1529
|
Data_Get_Struct(self, Draw, draw);
|
1519
1530
|
|
@@ -1522,6 +1533,8 @@ Draw_initialize(VALUE self)
|
|
1522
1533
|
draw->info = draw_options->info;
|
1523
1534
|
draw_options->info = NULL;
|
1524
1535
|
|
1536
|
+
RB_GC_GUARD(options);
|
1537
|
+
|
1525
1538
|
return self;
|
1526
1539
|
}
|
1527
1540
|
|
@@ -1560,12 +1573,14 @@ Draw_inspect(VALUE self)
|
|
1560
1573
|
VALUE Draw_alloc(VALUE class)
|
1561
1574
|
{
|
1562
1575
|
Draw *draw;
|
1563
|
-
|
1576
|
+
VALUE draw_obj;
|
1564
1577
|
|
1565
1578
|
draw = ALLOC(Draw);
|
1566
1579
|
memset(draw, 0, sizeof(Draw));
|
1567
1580
|
draw_obj = Data_Wrap_Struct(class, mark_Draw, destroy_Draw, draw);
|
1568
1581
|
|
1582
|
+
RB_GC_GUARD(draw_obj);
|
1583
|
+
|
1569
1584
|
return draw_obj;
|
1570
1585
|
}
|
1571
1586
|
|
@@ -1685,12 +1700,14 @@ VALUE
|
|
1685
1700
|
DrawOptions_alloc(VALUE class)
|
1686
1701
|
{
|
1687
1702
|
Draw *draw_options;
|
1688
|
-
|
1703
|
+
VALUE draw_options_obj;
|
1689
1704
|
|
1690
1705
|
draw_options = ALLOC(Draw);
|
1691
1706
|
memset(draw_options, 0, sizeof(Draw));
|
1692
1707
|
draw_options_obj = Data_Wrap_Struct(class, mark_Draw, destroy_Draw, draw_options);
|
1693
1708
|
|
1709
|
+
RB_GC_GUARD(draw_options_obj);
|
1710
|
+
|
1694
1711
|
return draw_options_obj;
|
1695
1712
|
}
|
1696
1713
|
|
@@ -1745,7 +1762,7 @@ DrawOptions_initialize(VALUE self)
|
|
1745
1762
|
VALUE
|
1746
1763
|
PolaroidOptions_alloc(VALUE class)
|
1747
1764
|
{
|
1748
|
-
|
1765
|
+
VALUE polaroid_obj;
|
1749
1766
|
ImageInfo *image_info;
|
1750
1767
|
Draw *draw;
|
1751
1768
|
|
@@ -1759,6 +1776,8 @@ PolaroidOptions_alloc(VALUE class)
|
|
1759
1776
|
|
1760
1777
|
polaroid_obj = Data_Wrap_Struct(class, NULL, destroy_Draw, draw);
|
1761
1778
|
|
1779
|
+
RB_GC_GUARD(polaroid_obj);
|
1780
|
+
|
1762
1781
|
return polaroid_obj;
|
1763
1782
|
}
|
1764
1783
|
|
@@ -1863,7 +1882,7 @@ static VALUE
|
|
1863
1882
|
get_dummy_tm_img(VALUE klass)
|
1864
1883
|
{
|
1865
1884
|
#define DUMMY_IMG_CLASS_VAR "@@_dummy_img_"
|
1866
|
-
|
1885
|
+
VALUE dummy_img = 0;
|
1867
1886
|
Info *info;
|
1868
1887
|
Image *image;
|
1869
1888
|
|
@@ -1887,6 +1906,8 @@ get_dummy_tm_img(VALUE klass)
|
|
1887
1906
|
}
|
1888
1907
|
dummy_img = rb_cv_get(klass, DUMMY_IMG_CLASS_VAR);
|
1889
1908
|
|
1909
|
+
RB_GC_GUARD(dummy_img);
|
1910
|
+
|
1890
1911
|
return dummy_img;
|
1891
1912
|
}
|
1892
1913
|
|
@@ -1918,7 +1939,7 @@ get_type_metrics(
|
|
1918
1939
|
#define ATTRS_L ((int)(sizeof(attrs)-1))
|
1919
1940
|
Image *image;
|
1920
1941
|
Draw *draw;
|
1921
|
-
|
1942
|
+
VALUE t;
|
1922
1943
|
TypeMetric metrics;
|
1923
1944
|
char *text = NULL;
|
1924
1945
|
long text_l;
|
@@ -1994,5 +2015,8 @@ get_type_metrics(
|
|
1994
2015
|
rb_raise(rb_eRuntimeError, "Can't measure text. Are the fonts installed? "
|
1995
2016
|
"Is the FreeType library installed?");
|
1996
2017
|
}
|
2018
|
+
|
2019
|
+
RB_GC_GUARD(t);
|
2020
|
+
|
1997
2021
|
return Import_TypeMetric(&metrics);
|
1998
2022
|
}
|
data/ext/RMagick/rmenum.c
CHANGED
@@ -78,10 +78,13 @@ VALUE
|
|
78
78
|
Enum_alloc(VALUE class)
|
79
79
|
{
|
80
80
|
MagickEnum *magick_enum;
|
81
|
-
|
81
|
+
VALUE enumr;
|
82
82
|
|
83
83
|
enumr = Data_Make_Struct(class, MagickEnum, NULL, NULL, magick_enum);
|
84
84
|
rb_obj_freeze(enumr);
|
85
|
+
|
86
|
+
RB_GC_GUARD(enumr);
|
87
|
+
|
85
88
|
return enumr;
|
86
89
|
}
|
87
90
|
|
@@ -230,7 +233,7 @@ VALUE
|
|
230
233
|
Enum_type_initialize(VALUE self, VALUE sym, VALUE val)
|
231
234
|
{
|
232
235
|
VALUE super_argv[2];
|
233
|
-
|
236
|
+
VALUE enumerators;
|
234
237
|
|
235
238
|
super_argv[0] = sym;
|
236
239
|
super_argv[1] = val;
|
@@ -244,6 +247,8 @@ Enum_type_initialize(VALUE self, VALUE sym, VALUE val)
|
|
244
247
|
enumerators = rb_cv_get(CLASS_OF(self), ENUMERATORS_CLASS_VAR);
|
245
248
|
(void) rb_ary_push(enumerators, self);
|
246
249
|
|
250
|
+
RB_GC_GUARD(enumerators);
|
251
|
+
|
247
252
|
return self;
|
248
253
|
}
|
249
254
|
|
@@ -286,8 +291,8 @@ Enum_type_inspect(VALUE self)
|
|
286
291
|
static VALUE
|
287
292
|
Enum_type_values(VALUE class)
|
288
293
|
{
|
289
|
-
|
290
|
-
|
294
|
+
VALUE enumerators, copy;
|
295
|
+
VALUE rv;
|
291
296
|
int x;
|
292
297
|
|
293
298
|
enumerators = rb_cv_get(class, ENUMERATORS_CLASS_VAR);
|
@@ -311,6 +316,10 @@ Enum_type_values(VALUE class)
|
|
311
316
|
rv = copy;
|
312
317
|
}
|
313
318
|
|
319
|
+
RB_GC_GUARD(enumerators);
|
320
|
+
RB_GC_GUARD(copy);
|
321
|
+
RB_GC_GUARD(rv);
|
322
|
+
|
314
323
|
return rv;
|
315
324
|
}
|
316
325
|
|
data/ext/RMagick/rmfill.c
CHANGED
@@ -675,7 +675,7 @@ TextureFill_initialize(VALUE self, VALUE texture_arg)
|
|
675
675
|
{
|
676
676
|
rm_TextureFill *fill;
|
677
677
|
Image *texture;
|
678
|
-
|
678
|
+
VALUE texture_image;
|
679
679
|
|
680
680
|
Data_Get_Struct(self, rm_TextureFill, fill);
|
681
681
|
|
@@ -686,6 +686,9 @@ TextureFill_initialize(VALUE self, VALUE texture_arg)
|
|
686
686
|
(void) ReferenceImage(texture);
|
687
687
|
|
688
688
|
fill->texture = texture;
|
689
|
+
|
690
|
+
RB_GC_GUARD(texture_image);
|
691
|
+
|
689
692
|
return self;
|
690
693
|
}
|
691
694
|
|
data/ext/RMagick/rmilist.c
CHANGED
@@ -44,7 +44,7 @@ ImageList_animate(int argc, VALUE *argv, VALUE self)
|
|
44
44
|
{
|
45
45
|
Image *images;
|
46
46
|
Info *info;
|
47
|
-
|
47
|
+
VALUE info_obj;
|
48
48
|
|
49
49
|
if (argc > 1)
|
50
50
|
{
|
@@ -74,6 +74,8 @@ ImageList_animate(int argc, VALUE *argv, VALUE self)
|
|
74
74
|
rm_check_image_exception(images, RetainOnError);
|
75
75
|
rm_split(images);
|
76
76
|
|
77
|
+
RB_GC_GUARD(info_obj);
|
78
|
+
|
77
79
|
return self;
|
78
80
|
}
|
79
81
|
|
@@ -202,7 +204,7 @@ ImageList_coalesce(VALUE self)
|
|
202
204
|
VALUE
|
203
205
|
ImageList_composite_layers(int argc, VALUE *argv, VALUE self)
|
204
206
|
{
|
205
|
-
|
207
|
+
VALUE source_images;
|
206
208
|
Image *dest, *source, *new_images;
|
207
209
|
RectangleInfo geometry;
|
208
210
|
CompositeOperator operator = OverCompositeOp;
|
@@ -242,6 +244,8 @@ ImageList_composite_layers(int argc, VALUE *argv, VALUE self)
|
|
242
244
|
rm_check_exception(exception, new_images, DestroyOnError);
|
243
245
|
(void) DestroyExceptionInfo(exception);
|
244
246
|
|
247
|
+
RB_GC_GUARD(source_images);
|
248
|
+
|
245
249
|
return rm_imagelist_from_images(new_images);
|
246
250
|
}
|
247
251
|
|
@@ -289,7 +293,7 @@ ImageList_display(VALUE self)
|
|
289
293
|
{
|
290
294
|
Image *images;
|
291
295
|
Info *info;
|
292
|
-
|
296
|
+
VALUE info_obj;
|
293
297
|
|
294
298
|
// Create a new Info object to use with this call
|
295
299
|
info_obj = rm_info_new();
|
@@ -302,6 +306,8 @@ ImageList_display(VALUE self)
|
|
302
306
|
rm_split(images);
|
303
307
|
rm_check_image_exception(images, RetainOnError);
|
304
308
|
|
309
|
+
RB_GC_GUARD(info_obj);
|
310
|
+
|
305
311
|
return self;
|
306
312
|
}
|
307
313
|
|
@@ -417,7 +423,7 @@ ImageList_map(int argc, VALUE *argv, VALUE self)
|
|
417
423
|
Image *images, *new_images = NULL;
|
418
424
|
Image *map;
|
419
425
|
unsigned int dither = MagickFalse;
|
420
|
-
|
426
|
+
VALUE scene, new_imagelist, t;
|
421
427
|
ExceptionInfo *exception;
|
422
428
|
|
423
429
|
#if defined(HAVE_REMAPIMAGES)
|
@@ -465,6 +471,10 @@ ImageList_map(int argc, VALUE *argv, VALUE self)
|
|
465
471
|
scene = rb_iv_get(self, "@scene");
|
466
472
|
(void) imagelist_scene_eq(new_imagelist, scene);
|
467
473
|
|
474
|
+
RB_GC_GUARD(scene);
|
475
|
+
RB_GC_GUARD(new_imagelist);
|
476
|
+
RB_GC_GUARD(t);
|
477
|
+
|
468
478
|
return new_imagelist;
|
469
479
|
}
|
470
480
|
|
@@ -485,7 +495,7 @@ ImageList_map(int argc, VALUE *argv, VALUE self)
|
|
485
495
|
VALUE
|
486
496
|
ImageList_montage(VALUE self)
|
487
497
|
{
|
488
|
-
|
498
|
+
VALUE montage_obj;
|
489
499
|
Montage *montage;
|
490
500
|
Image *new_images, *images;
|
491
501
|
ExceptionInfo *exception;
|
@@ -523,6 +533,8 @@ ImageList_montage(VALUE self)
|
|
523
533
|
|
524
534
|
rm_ensure_result(new_images);
|
525
535
|
|
536
|
+
RB_GC_GUARD(montage_obj);
|
537
|
+
|
526
538
|
return rm_imagelist_from_images(new_images);
|
527
539
|
}
|
528
540
|
|
@@ -754,7 +766,7 @@ ImageList_new(void)
|
|
754
766
|
VALUE
|
755
767
|
rm_imagelist_from_images(Image *images)
|
756
768
|
{
|
757
|
-
|
769
|
+
VALUE new_imagelist;
|
758
770
|
Image *image;
|
759
771
|
|
760
772
|
if (!images)
|
@@ -771,6 +783,9 @@ rm_imagelist_from_images(Image *images)
|
|
771
783
|
}
|
772
784
|
|
773
785
|
(void) rb_iv_set(new_imagelist, "@scene", INT2FIX(0));
|
786
|
+
|
787
|
+
RB_GC_GUARD(new_imagelist);
|
788
|
+
|
774
789
|
return new_imagelist;
|
775
790
|
}
|
776
791
|
|
@@ -790,7 +805,7 @@ images_from_imagelist(VALUE imagelist)
|
|
790
805
|
{
|
791
806
|
long x, len;
|
792
807
|
Image *head = NULL;
|
793
|
-
|
808
|
+
VALUE images, t;
|
794
809
|
|
795
810
|
len = check_imagelist_length(imagelist);
|
796
811
|
|
@@ -804,6 +819,9 @@ images_from_imagelist(VALUE imagelist)
|
|
804
819
|
AppendImageToList(&head, image);
|
805
820
|
}
|
806
821
|
|
822
|
+
RB_GC_GUARD(images);
|
823
|
+
RB_GC_GUARD(t);
|
824
|
+
|
807
825
|
return head;
|
808
826
|
}
|
809
827
|
|
@@ -837,7 +855,10 @@ imagelist_scene_eq(VALUE imagelist, VALUE scene)
|
|
837
855
|
static long
|
838
856
|
imagelist_length(VALUE imagelist)
|
839
857
|
{
|
840
|
-
|
858
|
+
VALUE images = rb_iv_get(imagelist, "@images");
|
859
|
+
|
860
|
+
RB_GC_GUARD(images);
|
861
|
+
|
841
862
|
return RARRAY_LEN(images);
|
842
863
|
}
|
843
864
|
|
@@ -942,7 +963,7 @@ ImageList_quantize(int argc, VALUE *argv, VALUE self)
|
|
942
963
|
Image *new_image;
|
943
964
|
QuantizeInfo quantize_info;
|
944
965
|
ExceptionInfo *exception;
|
945
|
-
|
966
|
+
VALUE new_imagelist, scene;
|
946
967
|
|
947
968
|
GetQuantizeInfo(&quantize_info);
|
948
969
|
|
@@ -1000,6 +1021,9 @@ ImageList_quantize(int argc, VALUE *argv, VALUE self)
|
|
1000
1021
|
scene = rb_iv_get(self, "@scene");
|
1001
1022
|
(void) rb_iv_set(new_imagelist, "@scene", scene);
|
1002
1023
|
|
1024
|
+
RB_GC_GUARD(new_imagelist);
|
1025
|
+
RB_GC_GUARD(scene);
|
1026
|
+
|
1003
1027
|
return new_imagelist;
|
1004
1028
|
}
|
1005
1029
|
|
@@ -1032,8 +1056,9 @@ ImageList_remap(int argc, VALUE *argv, VALUE self)
|
|
1032
1056
|
|
1033
1057
|
if (argc > 0 && argv[0] != Qnil)
|
1034
1058
|
{
|
1035
|
-
|
1059
|
+
VALUE t = rm_cur_image(argv[0]);
|
1036
1060
|
remap_image = rm_check_destroyed(t);
|
1061
|
+
RB_GC_GUARD(t);
|
1037
1062
|
}
|
1038
1063
|
|
1039
1064
|
GetQuantizeInfo(&quantize_info);
|
@@ -1087,8 +1112,8 @@ ImageList_to_blob(VALUE self)
|
|
1087
1112
|
{
|
1088
1113
|
Image *images, *image;
|
1089
1114
|
Info *info;
|
1090
|
-
|
1091
|
-
|
1115
|
+
VALUE info_obj;
|
1116
|
+
VALUE blob_str;
|
1092
1117
|
void *blob = NULL;
|
1093
1118
|
size_t length = 0;
|
1094
1119
|
ExceptionInfo *exception;
|
@@ -1141,6 +1166,9 @@ ImageList_to_blob(VALUE self)
|
|
1141
1166
|
blob_str = rb_str_new(blob, (long)length);
|
1142
1167
|
magick_free((void*)blob);
|
1143
1168
|
|
1169
|
+
RB_GC_GUARD(info_obj);
|
1170
|
+
RB_GC_GUARD(blob_str);
|
1171
|
+
|
1144
1172
|
return blob_str;
|
1145
1173
|
}
|
1146
1174
|
|
@@ -1164,7 +1192,7 @@ ImageList_write(VALUE self, VALUE file)
|
|
1164
1192
|
Image *images, *img;
|
1165
1193
|
Info *info;
|
1166
1194
|
const MagickInfo *m;
|
1167
|
-
|
1195
|
+
VALUE info_obj;
|
1168
1196
|
unsigned long scene;
|
1169
1197
|
ExceptionInfo *exception;
|
1170
1198
|
|
@@ -1230,5 +1258,8 @@ ImageList_write(VALUE self, VALUE file)
|
|
1230
1258
|
}
|
1231
1259
|
|
1232
1260
|
rm_split(images);
|
1261
|
+
|
1262
|
+
RB_GC_GUARD(info_obj);
|
1263
|
+
|
1233
1264
|
return self;
|
1234
1265
|
}
|