mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 19:22:45 +00:00 
			
		
		
		
	ProcFS: Check for empty Optional in read_bytes()
In read_bytes() we now check that the Optional "data" actually contains a value before use, avoiding a failing asserting in kernel space.
This commit is contained in:
		
							parent
							
								
									4d99856f95
								
							
						
					
					
						commit
						d063734f69
					
				
					 1 changed files with 8 additions and 4 deletions
				
			
		|  | @ -997,10 +997,14 @@ ssize_t ProcFSInode::read_bytes(off_t offset, ssize_t count, u8* buffer, FileDes | |||
|     } | ||||
| 
 | ||||
|     auto& data = generated_data; | ||||
|     ssize_t nread = min(static_cast<off_t>(data.value().size() - offset), static_cast<off_t>(count)); | ||||
|     memcpy(buffer, data.value().data() + offset, nread); | ||||
|     if (nread == 0 && description && description->generator_cache()) | ||||
|         description->generator_cache().clear(); | ||||
|     ssize_t nread = 0; | ||||
|     if (data.has_value()) { | ||||
|         nread = min(static_cast<off_t>(data.value().size() - offset), static_cast<off_t>(count)); | ||||
|         memcpy(buffer, data.value().data() + offset, nread); | ||||
|         if (nread == 0 && description && description->generator_cache()) | ||||
|             description->generator_cache().clear(); | ||||
|     } | ||||
| 
 | ||||
|     return nread; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Drew Stratford
						Drew Stratford