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.

@@ -317,7 +317,7 @@ VALUE
317
317
  Info_aset(int argc, VALUE *argv, VALUE self)
318
318
  {
319
319
  Info *info;
320
- volatile VALUE value;
320
+ VALUE value;
321
321
  char *format_p, *key_p, *value_p = NULL;
322
322
  long format_l, key_l;
323
323
  char ckey[MaxTextExtent];
@@ -373,6 +373,7 @@ Info_aset(int argc, VALUE *argv, VALUE self)
373
373
  }
374
374
  }
375
375
 
376
+ RB_GC_GUARD(value);
376
377
 
377
378
  return self;
378
379
  }
@@ -745,7 +746,7 @@ Info_define(int argc, VALUE *argv, VALUE self)
745
746
  long format_l, key_l;
746
747
  char ckey[100];
747
748
  unsigned int okay;
748
- volatile VALUE fmt_arg;
749
+ VALUE fmt_arg;
749
750
 
750
751
  Data_Get_Struct(self, Info, info);
751
752
 
@@ -777,6 +778,8 @@ Info_define(int argc, VALUE *argv, VALUE self)
777
778
  return Qnil;
778
779
  }
779
780
 
781
+ RB_GC_GUARD(fmt_arg);
782
+
780
783
  return self;
781
784
  }
782
785
 
@@ -903,7 +906,7 @@ VALUE
903
906
  Info_density_eq(VALUE self, VALUE density_arg)
904
907
  {
905
908
  Info *info;
906
- volatile VALUE density;
909
+ VALUE density;
907
910
  char *dens;
908
911
 
909
912
  Data_Get_Struct(self, Info, info);
@@ -924,6 +927,8 @@ Info_density_eq(VALUE self, VALUE density_arg)
924
927
 
925
928
  magick_clone_string(&info->density, dens);
926
929
 
930
+ RB_GC_GUARD(density);
931
+
927
932
  return self;
928
933
  }
929
934
 
@@ -1189,7 +1194,7 @@ Info_extract_eq(VALUE self, VALUE extract_arg)
1189
1194
  {
1190
1195
  Info *info;
1191
1196
  char *extr;
1192
- volatile VALUE extract;
1197
+ VALUE extract;
1193
1198
 
1194
1199
  Data_Get_Struct(self, Info, info);
1195
1200
 
@@ -1209,6 +1214,8 @@ Info_extract_eq(VALUE self, VALUE extract_arg)
1209
1214
 
1210
1215
  magick_clone_string(&info->extract, extr);
1211
1216
 
1217
+ RB_GC_GUARD(extract);
1218
+
1212
1219
  return self;
1213
1220
  }
1214
1221
 
@@ -1816,7 +1823,7 @@ VALUE
1816
1823
  Info_origin_eq(VALUE self, VALUE origin_arg)
1817
1824
  {
1818
1825
  Info *info;
1819
- volatile VALUE origin_str;
1826
+ VALUE origin_str;
1820
1827
  char *origin;
1821
1828
 
1822
1829
  Data_Get_Struct(self, Info, info);
@@ -1836,6 +1843,9 @@ Info_origin_eq(VALUE self, VALUE origin_arg)
1836
1843
  }
1837
1844
 
1838
1845
  (void) SetImageOption(info, "origin", origin);
1846
+
1847
+ RB_GC_GUARD(origin_str);
1848
+
1839
1849
  return self;
1840
1850
  }
1841
1851
 
@@ -1874,7 +1884,7 @@ VALUE
1874
1884
  Info_page_eq(VALUE self, VALUE page_arg)
1875
1885
  {
1876
1886
  Info *info;
1877
- volatile VALUE geom_str;
1887
+ VALUE geom_str;
1878
1888
  char *geometry;
1879
1889
 
1880
1890
  Data_Get_Struct(self, Info, info);
@@ -1894,6 +1904,8 @@ Info_page_eq(VALUE self, VALUE page_arg)
1894
1904
  }
1895
1905
  magick_clone_string(&info->page, geometry);
1896
1906
 
1907
+ RB_GC_GUARD(geom_str);
1908
+
1897
1909
  return self;
1898
1910
  }
1899
1911
 
@@ -2081,7 +2093,7 @@ VALUE
2081
2093
  Info_size_eq(VALUE self, VALUE size_arg)
2082
2094
  {
2083
2095
  Info *info;
2084
- volatile VALUE size;
2096
+ VALUE size;
2085
2097
  char *sz;
2086
2098
 
2087
2099
  Data_Get_Struct(self, Info, info);
@@ -2102,6 +2114,8 @@ Info_size_eq(VALUE self, VALUE size_arg)
2102
2114
 
2103
2115
  magick_clone_string(&info->size, sz);
2104
2116
 
2117
+ RB_GC_GUARD(size);
2118
+
2105
2119
  return self;
2106
2120
  }
2107
2121
 
@@ -2235,7 +2249,7 @@ VALUE
2235
2249
  Info_tile_offset_eq(VALUE self, VALUE offset)
2236
2250
  {
2237
2251
  Info *info;
2238
- volatile VALUE offset_str;
2252
+ VALUE offset_str;
2239
2253
  char *tile_offset;
2240
2254
 
2241
2255
  offset_str = rm_to_s(offset);
@@ -2249,6 +2263,9 @@ Info_tile_offset_eq(VALUE self, VALUE offset)
2249
2263
 
2250
2264
  (void) DeleteImageOption(info, "tile-offset");
2251
2265
  (void) SetImageOption(info, "tile-offset", tile_offset);
2266
+
2267
+ RB_GC_GUARD(offset_str);
2268
+
2252
2269
  return self;
2253
2270
  }
2254
2271
 
@@ -2513,7 +2530,7 @@ VALUE
2513
2530
  Info_alloc(VALUE class)
2514
2531
  {
2515
2532
  Info *info;
2516
- volatile VALUE info_obj;
2533
+ VALUE info_obj;
2517
2534
 
2518
2535
  info = CloneImageInfo(NULL);
2519
2536
  if (!info)
@@ -2521,6 +2538,9 @@ Info_alloc(VALUE class)
2521
2538
  rb_raise(rb_eNoMemError, "not enough memory to initialize Info object");
2522
2539
  }
2523
2540
  info_obj = Data_Wrap_Struct(class, NULL, destroy_Info, info);
2541
+
2542
+ RB_GC_GUARD(info_obj);
2543
+
2524
2544
  return info_obj;
2525
2545
  }
2526
2546
 
@@ -2538,9 +2558,12 @@ Info_alloc(VALUE class)
2538
2558
  VALUE
2539
2559
  rm_info_new(void)
2540
2560
  {
2541
- volatile VALUE info_obj;
2561
+ VALUE info_obj;
2542
2562
 
2543
2563
  info_obj = Info_alloc(Class_Info);
2564
+
2565
+ RB_GC_GUARD(info_obj);
2566
+
2544
2567
  return Info_initialize(info_obj);
2545
2568
  }
2546
2569
 
@@ -131,7 +131,7 @@ static void set_managed_memory(void)
131
131
  void
132
132
  Init_RMagick2(void)
133
133
  {
134
- volatile VALUE observable;
134
+ VALUE observable;
135
135
 
136
136
  MagickCoreGenesis("RMagick", MagickFalse);
137
137
 
@@ -860,6 +860,9 @@ Init_RMagick2(void)
860
860
  ENUMERATOR(DeactivateAlphaChannel)
861
861
  ENUMERATOR(ResetAlphaChannel) /* deprecated */
862
862
  ENUMERATOR(SetAlphaChannel)
863
+ #if defined(HAVE_ENUM_REMOVEALPHACHANNEL)
864
+ ENUMERATOR(RemoveAlphaChannel)
865
+ #endif
863
866
  #if defined(HAVE_ENUM_COPYALPHACHANNEL)
864
867
  ENUMERATOR(CopyAlphaChannel)
865
868
  ENUMERATOR(ExtractAlphaChannel)
@@ -1617,6 +1620,7 @@ Init_RMagick2(void)
1617
1620
  SetErrorHandler(rm_error_handler);
1618
1621
  SetWarningHandler(rm_warning_handler);
1619
1622
 
1623
+ RB_GC_GUARD(observable);
1620
1624
  }
1621
1625
 
1622
1626
 
@@ -1678,7 +1682,7 @@ static void
1678
1682
  version_constants(void)
1679
1683
  {
1680
1684
  const char *mgk_version;
1681
- volatile VALUE str;
1685
+ VALUE str;
1682
1686
  char long_version[1000];
1683
1687
 
1684
1688
  mgk_version = GetMagickVersion(NULL);
@@ -1703,6 +1707,7 @@ version_constants(void)
1703
1707
  rb_obj_freeze(str);
1704
1708
  rb_define_const(Module_Magick, "Long_version", str);
1705
1709
 
1710
+ RB_GC_GUARD(str);
1706
1711
  }
1707
1712
 
1708
1713
 
@@ -1714,7 +1719,7 @@ version_constants(void)
1714
1719
  static void
1715
1720
  features_constant(void)
1716
1721
  {
1717
- volatile VALUE features;
1722
+ VALUE features;
1718
1723
 
1719
1724
  #if defined(HAVE_GETMAGICKFEATURES)
1720
1725
  // 6.5.7 - latest (7.0.0)
@@ -1731,4 +1736,6 @@ features_constant(void)
1731
1736
 
1732
1737
  rb_obj_freeze(features);
1733
1738
  rb_define_const(Module_Magick, "Magick_features", features);
1739
+
1740
+ RB_GC_GUARD(features);
1734
1741
  }
@@ -63,7 +63,7 @@ Montage_alloc(VALUE class)
63
63
  MontageInfo *montage_info;
64
64
  Montage *montage;
65
65
  Info *image_info;
66
- volatile VALUE montage_obj;
66
+ VALUE montage_obj;
67
67
 
68
68
  // DO NOT call rm_info_new - we don't want to support an Info parm block.
69
69
  image_info = CloneImageInfo(NULL);
@@ -85,6 +85,8 @@ Montage_alloc(VALUE class)
85
85
  montage->compose = OverCompositeOp;
86
86
  montage_obj = Data_Wrap_Struct(class, NULL, destroy_Montage, montage);
87
87
 
88
+ RB_GC_GUARD(montage_obj);
89
+
88
90
  return montage_obj;
89
91
  }
90
92
 
@@ -256,12 +258,14 @@ VALUE
256
258
  Montage_frame_eq(VALUE self, VALUE frame_arg)
257
259
  {
258
260
  Montage *montage;
259
- volatile VALUE frame;
261
+ VALUE frame;
260
262
 
261
263
  Data_Get_Struct(self, Montage, montage);
262
264
  frame = rm_to_s(frame_arg);
263
265
  magick_clone_string(&montage->info->frame, StringValuePtr(frame));
264
266
 
267
+ RB_GC_GUARD(frame);
268
+
265
269
  return self;
266
270
  }
267
271
 
@@ -280,12 +284,14 @@ VALUE
280
284
  Montage_geometry_eq(VALUE self, VALUE geometry_arg)
281
285
  {
282
286
  Montage *montage;
283
- volatile VALUE geometry;
287
+ VALUE geometry;
284
288
 
285
289
  Data_Get_Struct(self, Montage, montage);
286
290
  geometry = rm_to_s(geometry_arg);
287
291
  magick_clone_string(&montage->info->geometry, StringValuePtr(geometry));
288
292
 
293
+ RB_GC_GUARD(geometry);
294
+
289
295
  return self;
290
296
  }
291
297
 
@@ -465,12 +471,14 @@ VALUE
465
471
  Montage_tile_eq(VALUE self, VALUE tile_arg)
466
472
  {
467
473
  Montage *montage;
468
- volatile VALUE tile;
474
+ VALUE tile;
469
475
 
470
476
  Data_Get_Struct(self, Montage, montage);
471
477
  tile = rm_to_s(tile_arg);
472
478
  magick_clone_string(&montage->info->tile, StringValuePtr(tile));
473
479
 
480
+ RB_GC_GUARD(tile);
481
+
474
482
  return self;
475
483
  }
476
484
 
@@ -294,7 +294,7 @@ Pixel_case_eq(VALUE self, VALUE other)
294
294
  VALUE
295
295
  Pixel_clone(VALUE self)
296
296
  {
297
- volatile VALUE clone;
297
+ VALUE clone;
298
298
 
299
299
  clone = Pixel_dup(self);
300
300
  if (OBJ_FROZEN(self))
@@ -302,6 +302,8 @@ Pixel_clone(VALUE self)
302
302
  OBJ_FREEZE(clone);
303
303
  }
304
304
 
305
+ RB_GC_GUARD(clone);
306
+
305
307
  return clone;
306
308
  }
307
309
 
@@ -321,7 +323,7 @@ VALUE
321
323
  Pixel_dup(VALUE self)
322
324
  {
323
325
  Pixel *pixel;
324
- volatile VALUE dup;
326
+ VALUE dup;
325
327
 
326
328
  pixel = ALLOC(Pixel);
327
329
  memset(pixel, '\0', sizeof(Pixel));
@@ -330,6 +332,9 @@ Pixel_dup(VALUE self)
330
332
  {
331
333
  (void) rb_obj_taint(dup);
332
334
  }
335
+
336
+ RB_GC_GUARD(dup);
337
+
333
338
  return rb_funcall(dup, rm_ID_initialize_copy, 1, self);
334
339
  }
335
340
 
@@ -794,7 +799,7 @@ VALUE
794
799
  Pixel_marshal_dump(VALUE self)
795
800
  {
796
801
  Pixel *pixel;
797
- volatile VALUE dpixel;
802
+ VALUE dpixel;
798
803
 
799
804
  Data_Get_Struct(self, Pixel, pixel);
800
805
  dpixel = rb_hash_new();
@@ -802,6 +807,9 @@ Pixel_marshal_dump(VALUE self)
802
807
  rb_hash_aset(dpixel, CSTR2SYM("green"), QUANTUM2NUM(pixel->green));
803
808
  rb_hash_aset(dpixel, CSTR2SYM("blue"), QUANTUM2NUM(pixel->blue));
804
809
  rb_hash_aset(dpixel, CSTR2SYM("opacity"), QUANTUM2NUM(pixel->opacity));
810
+
811
+ RB_GC_GUARD(dpixel);
812
+
805
813
  return dpixel;
806
814
  }
807
815
 
@@ -892,7 +900,7 @@ Pixel_to_hsla(VALUE self)
892
900
  {
893
901
  double hue, sat, lum, alpha;
894
902
  Pixel *pixel;
895
- volatile VALUE hsla;
903
+ VALUE hsla;
896
904
 
897
905
  Data_Get_Struct(self, Pixel, pixel);
898
906
 
@@ -915,6 +923,9 @@ Pixel_to_hsla(VALUE self)
915
923
  }
916
924
 
917
925
  hsla = rb_ary_new3(4, rb_float_new(hue), rb_float_new(sat), rb_float_new(lum), rb_float_new(alpha));
926
+
927
+ RB_GC_GUARD(hsla);
928
+
918
929
  return hsla;
919
930
  }
920
931
 
@@ -933,7 +944,7 @@ Pixel_to_HSL(VALUE self)
933
944
  {
934
945
  Pixel *pixel;
935
946
  double hue, saturation, luminosity;
936
- volatile VALUE hsl;
947
+ VALUE hsl;
937
948
 
938
949
  Data_Get_Struct(self, Pixel, pixel);
939
950
 
@@ -943,6 +954,8 @@ Pixel_to_HSL(VALUE self)
943
954
  hsl = rb_ary_new3(3, rb_float_new(hue), rb_float_new(saturation),
944
955
  rb_float_new(luminosity));
945
956
 
957
+ RB_GC_GUARD(hsl);
958
+
946
959
  return hsl;
947
960
  }
948
961
 
@@ -65,7 +65,7 @@ Import_AffineMatrix(AffineMatrix *affine)
65
65
  void
66
66
  Export_AffineMatrix(AffineMatrix *am, VALUE st)
67
67
  {
68
- volatile VALUE values, v;
68
+ VALUE values, v;
69
69
 
70
70
  if (CLASS_OF(st) != Class_AffineMatrix)
71
71
  {
@@ -85,6 +85,9 @@ Export_AffineMatrix(AffineMatrix *am, VALUE st)
85
85
  am->tx = v == Qnil ? 0.0 : NUM2DBL(v);
86
86
  v = rb_ary_entry(values, 5);
87
87
  am->ty = v == Qnil ? 0.0 : NUM2DBL(v);
88
+
89
+ RB_GC_GUARD(values);
90
+ RB_GC_GUARD(v);
88
91
  }
89
92
 
90
93
 
@@ -99,16 +102,21 @@ Export_AffineMatrix(AffineMatrix *am, VALUE st)
99
102
  VALUE
100
103
  ChromaticityInfo_new(ChromaticityInfo *ci)
101
104
  {
102
- volatile VALUE red_primary;
103
- volatile VALUE green_primary;
104
- volatile VALUE blue_primary;
105
- volatile VALUE white_point;
105
+ VALUE red_primary;
106
+ VALUE green_primary;
107
+ VALUE blue_primary;
108
+ VALUE white_point;
106
109
 
107
110
  red_primary = Import_PrimaryInfo(&ci->red_primary);
108
111
  green_primary = Import_PrimaryInfo(&ci->green_primary);
109
112
  blue_primary = Import_PrimaryInfo(&ci->blue_primary);
110
113
  white_point = Import_PrimaryInfo(&ci->white_point);
111
114
 
115
+ RB_GC_GUARD(red_primary);
116
+ RB_GC_GUARD(green_primary);
117
+ RB_GC_GUARD(blue_primary);
118
+ RB_GC_GUARD(white_point);
119
+
112
120
  return rb_funcall(Class_Chromaticity, rm_ID_new, 4
113
121
  , red_primary, green_primary, blue_primary, white_point);
114
122
  }
@@ -126,9 +134,9 @@ ChromaticityInfo_new(ChromaticityInfo *ci)
126
134
  void
127
135
  Export_ChromaticityInfo(ChromaticityInfo *ci, VALUE chrom)
128
136
  {
129
- volatile VALUE chrom_members;
130
- volatile VALUE red_primary, green_primary, blue_primary, white_point;
131
- volatile VALUE entry_members, x, y;
137
+ VALUE chrom_members;
138
+ VALUE red_primary, green_primary, blue_primary, white_point;
139
+ VALUE entry_members, x, y;
132
140
  ID values_id;
133
141
 
134
142
  if (CLASS_OF(chrom) != Class_Chromaticity)
@@ -176,6 +184,15 @@ Export_ChromaticityInfo(ChromaticityInfo *ci, VALUE chrom)
176
184
  y = rb_ary_entry(entry_members, 1); // white_point.y
177
185
  ci->white_point.y = y == Qnil ? 0.0 : NUM2DBL(y);
178
186
  ci->white_point.z = 0.0;
187
+
188
+ RB_GC_GUARD(chrom_members);
189
+ RB_GC_GUARD(red_primary);
190
+ RB_GC_GUARD(green_primary);
191
+ RB_GC_GUARD(blue_primary);
192
+ RB_GC_GUARD(white_point);
193
+ RB_GC_GUARD(entry_members);
194
+ RB_GC_GUARD(x);
195
+ RB_GC_GUARD(y);
179
196
  }
180
197
 
181
198
 
@@ -219,9 +236,9 @@ VALUE
219
236
  Import_ColorInfo(const ColorInfo *ci)
220
237
  {
221
238
  ComplianceType compliance_type;
222
- volatile VALUE name;
223
- volatile VALUE compliance;
224
- volatile VALUE color;
239
+ VALUE name;
240
+ VALUE compliance;
241
+ VALUE color;
225
242
 
226
243
  name = rb_str_new2(ci->name);
227
244
 
@@ -229,6 +246,10 @@ Import_ColorInfo(const ColorInfo *ci)
229
246
  compliance = ComplianceType_new(compliance_type);
230
247
  color = Pixel_from_MagickPixelPacket(&(ci->color));
231
248
 
249
+ RB_GC_GUARD(name);
250
+ RB_GC_GUARD(compliance);
251
+ RB_GC_GUARD(color);
252
+
232
253
  return rb_funcall(Class_Color, rm_ID_new, 3
233
254
  , name, compliance, color);
234
255
  }
@@ -246,7 +267,7 @@ void
246
267
  Export_ColorInfo(ColorInfo *ci, VALUE st)
247
268
  {
248
269
  Pixel *pixel;
249
- volatile VALUE members, m;
270
+ VALUE members, m;
250
271
 
251
272
  if (CLASS_OF(st) != Class_Color)
252
273
  {
@@ -281,6 +302,9 @@ Export_ColorInfo(ColorInfo *ci, VALUE st)
281
302
  ci->color.opacity = (MagickRealType) OpaqueOpacity;
282
303
  ci->color.index = (MagickRealType) 0;
283
304
  }
305
+
306
+ RB_GC_GUARD(members);
307
+ RB_GC_GUARD(m);
284
308
  }
285
309
 
286
310
 
@@ -441,9 +465,9 @@ ComplianceType_new(ComplianceType compliance)
441
465
  VALUE
442
466
  Import_TypeInfo(const TypeInfo *ti)
443
467
  {
444
- volatile VALUE name, description, family;
445
- volatile VALUE style, stretch, weight;
446
- volatile VALUE encoding, foundry, format;
468
+ VALUE name, description, family;
469
+ VALUE style, stretch, weight;
470
+ VALUE encoding, foundry, format;
447
471
 
448
472
  name = rb_str_new2(ti->name);
449
473
  family = rb_str_new2(ti->family);
@@ -455,6 +479,16 @@ Import_TypeInfo(const TypeInfo *ti)
455
479
  foundry = ti->foundry ? rb_str_new2(ti->foundry) : Qnil;
456
480
  format = ti->format ? rb_str_new2(ti->format) : Qnil;
457
481
 
482
+ RB_GC_GUARD(name);
483
+ RB_GC_GUARD(description);
484
+ RB_GC_GUARD(family);
485
+ RB_GC_GUARD(style);
486
+ RB_GC_GUARD(stretch);
487
+ RB_GC_GUARD(weight);
488
+ RB_GC_GUARD(encoding);
489
+ RB_GC_GUARD(foundry);
490
+ RB_GC_GUARD(format);
491
+
458
492
  return rb_funcall(Class_Font, rm_ID_new, 9
459
493
  , name, description, family, style
460
494
  , stretch, weight, encoding, foundry, format);
@@ -472,7 +506,7 @@ Import_TypeInfo(const TypeInfo *ti)
472
506
  void
473
507
  Export_TypeInfo(TypeInfo *ti, VALUE st)
474
508
  {
475
- volatile VALUE members, m;
509
+ VALUE members, m;
476
510
 
477
511
  if (CLASS_OF(st) != Class_Font)
478
512
  {
@@ -511,6 +545,9 @@ Export_TypeInfo(TypeInfo *ti, VALUE st)
511
545
  m = rb_ary_entry(members, 8);
512
546
  if (m != Qnil)
513
547
  (void) CloneString((char **)&(ti->format), StringValuePtr(m));
548
+
549
+ RB_GC_GUARD(members);
550
+ RB_GC_GUARD(m);
514
551
  }
515
552
 
516
553
 
@@ -616,7 +653,7 @@ Import_PointInfo(PointInfo *p)
616
653
  void
617
654
  Export_PointInfo(PointInfo *pi, VALUE sp)
618
655
  {
619
- volatile VALUE members, m;
656
+ VALUE members, m;
620
657
 
621
658
  if (CLASS_OF(sp) != Class_Point)
622
659
  {
@@ -628,6 +665,9 @@ Export_PointInfo(PointInfo *pi, VALUE sp)
628
665
  pi->x = m == Qnil ? 0.0 : NUM2DBL(m);
629
666
  m = rb_ary_entry(members, 1);
630
667
  pi->y = m == Qnil ? 0.0 : NUM2DBL(m);
668
+
669
+ RB_GC_GUARD(members);
670
+ RB_GC_GUARD(m);
631
671
  }
632
672
 
633
673
 
@@ -658,7 +698,7 @@ Import_PrimaryInfo(PrimaryInfo *p)
658
698
  void
659
699
  Export_PrimaryInfo(PrimaryInfo *pi, VALUE sp)
660
700
  {
661
- volatile VALUE members, m;
701
+ VALUE members, m;
662
702
 
663
703
  if (CLASS_OF(sp) != Class_Primary)
664
704
  {
@@ -672,6 +712,9 @@ Export_PrimaryInfo(PrimaryInfo *pi, VALUE sp)
672
712
  pi->y = m == Qnil ? 0.0 : NUM2DBL(m);
673
713
  m = rb_ary_entry(members, 2);
674
714
  pi->z = m == Qnil ? 0.0 : NUM2DBL(m);
715
+
716
+ RB_GC_GUARD(members);
717
+ RB_GC_GUARD(m);
675
718
  }
676
719
 
677
720
 
@@ -707,14 +750,20 @@ PrimaryInfo_to_s(VALUE self)
707
750
  VALUE
708
751
  Import_RectangleInfo(RectangleInfo *rect)
709
752
  {
710
- volatile VALUE width;
711
- volatile VALUE height;
712
- volatile VALUE x, y;
753
+ VALUE width;
754
+ VALUE height;
755
+ VALUE x, y;
713
756
 
714
757
  width = UINT2NUM(rect->width);
715
758
  height = UINT2NUM(rect->height);
716
759
  x = INT2NUM(rect->x);
717
760
  y = INT2NUM(rect->y);
761
+
762
+ RB_GC_GUARD(width);
763
+ RB_GC_GUARD(height);
764
+ RB_GC_GUARD(x);
765
+ RB_GC_GUARD(y);
766
+
718
767
  return rb_funcall(Class_Rectangle, rm_ID_new, 4
719
768
  , width, height, x, y);
720
769
  }
@@ -731,7 +780,7 @@ Import_RectangleInfo(RectangleInfo *rect)
731
780
  void
732
781
  Export_RectangleInfo(RectangleInfo *rect, VALUE sr)
733
782
  {
734
- volatile VALUE members, m;
783
+ VALUE members, m;
735
784
 
736
785
  if (CLASS_OF(sr) != Class_Rectangle)
737
786
  {
@@ -747,6 +796,9 @@ Export_RectangleInfo(RectangleInfo *rect, VALUE sr)
747
796
  rect->x = m == Qnil ? 0 : NUM2LONG (m);
748
797
  m = rb_ary_entry(members, 3);
749
798
  rect->y = m == Qnil ? 0 : NUM2LONG (m);
799
+
800
+ RB_GC_GUARD(members);
801
+ RB_GC_GUARD(m);
750
802
  }
751
803
 
752
804
 
@@ -783,12 +835,18 @@ RectangleInfo_to_s(VALUE self)
783
835
  VALUE
784
836
  Import_SegmentInfo(SegmentInfo *segment)
785
837
  {
786
- volatile VALUE x1, y1, x2, y2;
838
+ VALUE x1, y1, x2, y2;
787
839
 
788
840
  x1 = rb_float_new(segment->x1);
789
841
  y1 = rb_float_new(segment->y1);
790
842
  x2 = rb_float_new(segment->x2);
791
843
  y2 = rb_float_new(segment->y2);
844
+
845
+ RB_GC_GUARD(x1);
846
+ RB_GC_GUARD(y1);
847
+ RB_GC_GUARD(x2);
848
+ RB_GC_GUARD(y2);
849
+
792
850
  return rb_funcall(Class_Segment, rm_ID_new, 4, x1, y1, x2, y2);
793
851
  }
794
852
 
@@ -804,7 +862,7 @@ Import_SegmentInfo(SegmentInfo *segment)
804
862
  void
805
863
  Export_SegmentInfo(SegmentInfo *segment, VALUE s)
806
864
  {
807
- volatile VALUE members, m;
865
+ VALUE members, m;
808
866
 
809
867
  if (CLASS_OF(s) != Class_Segment)
810
868
  {
@@ -821,6 +879,9 @@ Export_SegmentInfo(SegmentInfo *segment, VALUE s)
821
879
  segment->x2 = m == Qnil ? 0.0 : NUM2DBL(m);
822
880
  m = rb_ary_entry(members, 3);
823
881
  segment->y2 = m == Qnil ? 0.0 : NUM2DBL(m);
882
+
883
+ RB_GC_GUARD(members);
884
+ RB_GC_GUARD(m);
824
885
  }
825
886
 
826
887
 
@@ -943,10 +1004,10 @@ StyleType_new(StyleType style)
943
1004
  VALUE
944
1005
  Import_TypeMetric(TypeMetric *tm)
945
1006
  {
946
- volatile VALUE pixels_per_em;
947
- volatile VALUE ascent, descent;
948
- volatile VALUE width, height, max_advance;
949
- volatile VALUE bounds, underline_position, underline_thickness;
1007
+ VALUE pixels_per_em;
1008
+ VALUE ascent, descent;
1009
+ VALUE width, height, max_advance;
1010
+ VALUE bounds, underline_position, underline_thickness;
950
1011
 
951
1012
  pixels_per_em = Import_PointInfo(&tm->pixels_per_em);
952
1013
  ascent = rb_float_new(tm->ascent);
@@ -958,6 +1019,16 @@ Import_TypeMetric(TypeMetric *tm)
958
1019
  underline_position = rb_float_new(tm->underline_position);
959
1020
  underline_thickness = rb_float_new(tm->underline_position);
960
1021
 
1022
+ RB_GC_GUARD(pixels_per_em);
1023
+ RB_GC_GUARD(ascent);
1024
+ RB_GC_GUARD(descent);
1025
+ RB_GC_GUARD(width);
1026
+ RB_GC_GUARD(height);
1027
+ RB_GC_GUARD(max_advance);
1028
+ RB_GC_GUARD(bounds);
1029
+ RB_GC_GUARD(underline_position);
1030
+ RB_GC_GUARD(underline_thickness);
1031
+
961
1032
  return rb_funcall(Class_TypeMetric, rm_ID_new, 9
962
1033
  , pixels_per_em, ascent, descent, width
963
1034
  , height, max_advance, bounds
@@ -976,8 +1047,8 @@ Import_TypeMetric(TypeMetric *tm)
976
1047
  void
977
1048
  Export_TypeMetric(TypeMetric *tm, VALUE st)
978
1049
  {
979
- volatile VALUE members, m;
980
- volatile VALUE pixels_per_em;
1050
+ VALUE members, m;
1051
+ VALUE pixels_per_em;
981
1052
 
982
1053
  if (CLASS_OF(st) != Class_TypeMetric)
983
1054
  {
@@ -1007,6 +1078,10 @@ Export_TypeMetric(TypeMetric *tm, VALUE st)
1007
1078
  tm->underline_position = m == Qnil ? 0.0 : NUM2DBL(m);
1008
1079
  m = rb_ary_entry(members, 8);
1009
1080
  tm->underline_thickness = m == Qnil ? 0.0 : NUM2DBL(m);
1081
+
1082
+ RB_GC_GUARD(members);
1083
+ RB_GC_GUARD(m);
1084
+ RB_GC_GUARD(pixels_per_em);
1010
1085
  }
1011
1086
 
1012
1087
 
@@ -1022,7 +1097,7 @@ Export_TypeMetric(TypeMetric *tm, VALUE st)
1022
1097
  VALUE
1023
1098
  TypeMetric_to_s(VALUE self)
1024
1099
  {
1025
- volatile VALUE str;
1100
+ VALUE str;
1026
1101
  TypeMetric tm;
1027
1102
  char temp[200];
1028
1103
  int len;
@@ -1042,6 +1117,8 @@ TypeMetric_to_s(VALUE self)
1042
1117
  len = sprintf(temp, "underline_position=%g underline_thickness=%g", tm.underline_position, tm.underline_thickness);
1043
1118
  rb_str_cat(str, temp, len);
1044
1119
 
1120
+ RB_GC_GUARD(str);
1121
+
1045
1122
  return str;
1046
1123
  }
1047
1124