mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	vm_eval.c (rb_adjust_argv_kw_splat): avoid memcpy with zero length
A method call is often with `argc = 1` and `argv = &v` where v is a VALUE, and some functions shift the arguments by `argc-1` and `argv+1` (for example, rb_sym_proc_call). I'm unsure whether it is safe or not to pass a pointer `argv+1` to memcpy with zero length, but Coverity Scan complains it. So this attempts to suppress the warning by explicit check of the length.
This commit is contained in:
		
							parent
							
								
									b439ee1b8f
								
							
						
					
					
						commit
						d0e30fc955
					
				
					 1 changed files with 1 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -244,7 +244,7 @@ rb_adjust_argv_kw_splat(int *argc, const VALUE **argv, int *kw_splat)
 | 
			
		|||
            int n = *argc;
 | 
			
		||||
            VALUE v;
 | 
			
		||||
            VALUE *ptr = rb_alloc_tmp_buffer2(&v, n+1, sizeof(VALUE));
 | 
			
		||||
            memcpy(ptr, *argv, sizeof(VALUE)*n);
 | 
			
		||||
            if (n) memcpy(ptr, *argv, sizeof(VALUE)*n);
 | 
			
		||||
            ptr[n] = rb_hash_new();
 | 
			
		||||
            *argc = ++n;
 | 
			
		||||
            *argv = ptr;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue