mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 15:32:46 +00:00 
			
		
		
		
	Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe
This commit is contained in:
		
							parent
							
								
									3a9f00c59b
								
							
						
					
					
						commit
						97e97bccab
					
				
					 105 changed files with 629 additions and 290 deletions
				
			
		|  | @ -224,7 +224,7 @@ public: | |||
|         size_t nwritten = 0; | ||||
|         while (bytes.size() - nwritten > 0) { | ||||
|             if ((m_write_offset + nwritten) % chunk_size == 0) | ||||
|                 m_chunks.append(ByteBuffer::create_uninitialized(chunk_size)); | ||||
|                 m_chunks.append(ByteBuffer::create_uninitialized(chunk_size).release_value()); // FIXME: Handle possible OOM situation.
 | ||||
| 
 | ||||
|             nwritten += bytes.slice(nwritten).copy_trimmed_to(m_chunks.last().bytes().slice((m_write_offset + nwritten) % chunk_size)); | ||||
|         } | ||||
|  | @ -241,7 +241,8 @@ public: | |||
| 
 | ||||
|     ByteBuffer copy_into_contiguous_buffer() const | ||||
|     { | ||||
|         auto buffer = ByteBuffer::create_uninitialized(size()); | ||||
|         // FIXME: Handle possible OOM situation.
 | ||||
|         auto buffer = ByteBuffer::create_uninitialized(size()).release_value(); | ||||
| 
 | ||||
|         const auto nread = read_without_consuming(buffer); | ||||
|         VERIFY(nread == buffer.size()); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Ali Mohammad Pur
						Ali Mohammad Pur