@@ -311,8 +311,10 @@ char_to_option(int c)
311
311
return val ;
312
312
}
313
313
314
+ static const int OPTBUF_SIZE = 4 ;
315
+
314
316
static char *
315
- option_to_str (char str [4 ], int options )
317
+ option_to_str (char str [OPTBUF_SIZE ], int options )
316
318
{
317
319
char * p = str ;
318
320
if (options & ONIG_OPTION_MULTILINE ) * p ++ = 'm' ;
@@ -462,7 +464,7 @@ rb_reg_desc(const char *s, long len, VALUE re)
462
464
rb_reg_expr_str (str , s , len , enc , resenc , '/' );
463
465
rb_str_buf_cat2 (str , "/" );
464
466
if (re ) {
465
- char opts [4 ];
467
+ char opts [OPTBUF_SIZE ];
466
468
rb_reg_check (re );
467
469
if (* option_to_str (opts , RREGEXP_PTR (re )-> options ))
468
470
rb_str_buf_cat2 (str , opts );
@@ -554,7 +556,7 @@ rb_reg_str_with_term(VALUE re, int term)
554
556
long len ;
555
557
const UChar * ptr ;
556
558
VALUE str = rb_str_buf_new2 ("(?" );
557
- char optbuf [5 ];
559
+ char optbuf [OPTBUF_SIZE + 1 ]; /* for '-' */
558
560
rb_encoding * enc = rb_enc_get (re );
559
561
560
562
rb_reg_check (re );
@@ -668,7 +670,7 @@ rb_reg_raise(const char *s, long len, const char *err, VALUE re)
668
670
static VALUE
669
671
rb_enc_reg_error_desc (const char * s , long len , rb_encoding * enc , int options , const char * err )
670
672
{
671
- char opts [6 ];
673
+ char opts [OPTBUF_SIZE + 1 ]; /* for '/' */
672
674
VALUE desc = rb_str_buf_new2 (err );
673
675
rb_encoding * resenc = rb_default_internal_encoding ();
674
676
if (resenc == NULL ) resenc = rb_default_external_encoding ();
0 commit comments