mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:22:46 +00:00 
			
		
		
		
	LibWeb: Fix crash in get_response_mime_type()
We were creating a ref-counted HeaderList object on the stack, which then crashed in ~RefCounted() on scope exit, since nobody had adopted it.
This commit is contained in:
		
							parent
							
								
									8fa459f2d6
								
							
						
					
					
						commit
						e6eb8a9f06
					
				
					 1 changed files with 3 additions and 3 deletions
				
			
		|  | @ -215,17 +215,17 @@ MimeSniff::MimeType XMLHttpRequest::get_final_mime_type() const | ||||||
| MimeSniff::MimeType XMLHttpRequest::get_response_mime_type() const | MimeSniff::MimeType XMLHttpRequest::get_response_mime_type() const | ||||||
| { | { | ||||||
|     // FIXME: Use an actual HeaderList for XHR headers.
 |     // FIXME: Use an actual HeaderList for XHR headers.
 | ||||||
|     Fetch::Infrastructure::HeaderList header_list; |     auto header_list = make_ref_counted<Fetch::Infrastructure::HeaderList>(); | ||||||
|     for (auto const& entry : m_response_headers) { |     for (auto const& entry : m_response_headers) { | ||||||
|         auto header = Fetch::Infrastructure::Header { |         auto header = Fetch::Infrastructure::Header { | ||||||
|             .name = MUST(ByteBuffer::copy(entry.key.bytes())), |             .name = MUST(ByteBuffer::copy(entry.key.bytes())), | ||||||
|             .value = MUST(ByteBuffer::copy(entry.value.bytes())), |             .value = MUST(ByteBuffer::copy(entry.value.bytes())), | ||||||
|         }; |         }; | ||||||
|         MUST(header_list.append(move(header))); |         MUST(header_list->append(move(header))); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // 1. Let mimeType be the result of extracting a MIME type from xhr’s response’s header list.
 |     // 1. Let mimeType be the result of extracting a MIME type from xhr’s response’s header list.
 | ||||||
|     auto mime_type = header_list.extract_mime_type(); |     auto mime_type = header_list->extract_mime_type(); | ||||||
| 
 | 
 | ||||||
|     // 2. If mimeType is failure, then set mimeType to text/xml.
 |     // 2. If mimeType is failure, then set mimeType to text/xml.
 | ||||||
|     if (!mime_type.has_value()) |     if (!mime_type.has_value()) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling