mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	rawmidi: virtual: fix reading into a small buffer
In the special case for handling partial messages, the pointer calculations were wrong, which would result in data corruption. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Reviewd-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
		
							parent
							
								
									e4377b1645
								
							
						
					
					
						commit
						d71f294566
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
					@ -263,8 +263,8 @@ static ssize_t snd_rawmidi_virtual_read(snd_rawmidi_t *rmidi, void *buffer, size
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		size1 = virt->in_buf_size - virt->in_buf_ofs;
 | 
							size1 = virt->in_buf_size - virt->in_buf_ofs;
 | 
				
			||||||
		if ((size_t)size1 > size) {
 | 
							if ((size_t)size1 > size) {
 | 
				
			||||||
			virt->in_buf_ofs += size1 - size;
 | 
								memcpy(buffer, virt->in_buf_ptr + virt->in_buf_ofs, size);
 | 
				
			||||||
			memcpy(buffer, virt->in_buf_ptr, size);
 | 
								virt->in_buf_ofs += size;
 | 
				
			||||||
			result += size;
 | 
								result += size;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue