mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Fix bug when slicing a string with broken encoding
Commit aa2a428 introduced a bug where non-embedded string slices copied
the encoding of the original string. If the original string had a broken
encoding but the slice has valid encoding, then the slice would be
incorrectly marked as broken encoding.
			
			
This commit is contained in:
		
							parent
							
								
									6f8d17e43c
								
							
						
					
					
						commit
						28a572f8bf
					
				
				
				Notes:
				
					git
				
				2022-09-28 22:05:54 +09:00 
				
			
			
			
		
		
					 1 changed files with 1 additions and 0 deletions
				
			
		
							
								
								
									
										1
									
								
								string.c
									
										
									
									
									
								
							
							
						
						
									
										1
									
								
								string.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -2811,6 +2811,7 @@ str_subseq(VALUE str, long beg, long len)
 | 
			
		|||
    }
 | 
			
		||||
    else {
 | 
			
		||||
        str2 = str_new_shared(rb_cString, str);
 | 
			
		||||
        ENC_CODERANGE_CLEAR(str2);
 | 
			
		||||
        RSTRING(str2)->as.heap.ptr += beg;
 | 
			
		||||
        if (RSTRING(str2)->as.heap.len > len) {
 | 
			
		||||
            RSTRING(str2)->as.heap.len = len;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue