mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 10:52:44 +00:00 
			
		
		
		
	 1d846e5591
			
		
	
	
		1d846e5591
		
	
	
	
	
		
			
			Not visiting the field holding SubtleCrypto in Crypto caused subtle crashes all over the Value functions, due to accessing SubtleCrypto after it was garbage collected (and potentially replaced by a new cell). This meant that the crashes were only appearing in Value::to_boolean, Value::typeof, etc. Which then held pointer to things that looked like Shapes, Environments and other non-Object Cells. To find the actual cause, all pointer used to construct Values were checked and if a pointer was none of the allowed types, the backtrace is logged. Co-authored-by: Luke Wilde <lukew@serenityos.org>
		
			
				
	
	
		
			40 lines
		
	
	
	
		
			891 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
	
		
			891 B
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2021, Idan Horowitz <idan.horowitz@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <LibWeb/Bindings/PlatformObject.h>
 | |
| #include <LibWeb/Crypto/SubtleCrypto.h>
 | |
| #include <LibWeb/DOM/ExceptionOr.h>
 | |
| 
 | |
| namespace Web::Crypto {
 | |
| 
 | |
| class Crypto : public Bindings::PlatformObject {
 | |
|     WEB_PLATFORM_OBJECT(Crypto, Bindings::PlatformObject);
 | |
| 
 | |
| public:
 | |
|     static JS::NonnullGCPtr<Crypto> create(HTML::Window&);
 | |
| 
 | |
|     virtual ~Crypto() override;
 | |
| 
 | |
|     JS::NonnullGCPtr<SubtleCrypto> subtle() const;
 | |
| 
 | |
|     DOM::ExceptionOr<JS::Value> get_random_values(JS::Value array) const;
 | |
|     String random_uuid() const;
 | |
| 
 | |
| protected:
 | |
|     virtual void visit_edges(Cell::Visitor&) override;
 | |
| 
 | |
| private:
 | |
|     explicit Crypto(HTML::Window&);
 | |
|     virtual void initialize(JS::Realm&) override;
 | |
| 
 | |
|     JS::GCPtr<SubtleCrypto> m_subtle;
 | |
| };
 | |
| 
 | |
| }
 | |
| 
 | |
| WRAPPER_HACK(Crypto, Web::Crypto)
 |