mirror of
				https://github.com/YosysHQ/yosys
				synced 2025-10-29 18:52:30 +00:00 
			
		
		
		
	Throw runtime exception when trying to convert a c++-pointer to a
python-object in case the pointer is a nullptr to avoid a segfault. Fixes #1090
This commit is contained in:
		
							parent
							
								
									de26328130
								
							
						
					
					
						commit
						3a1a41bdb1
					
				
					 1 changed files with 3 additions and 0 deletions
				
			
		|  | @ -779,6 +779,9 @@ class WClass: | ||||||
| 
 | 
 | ||||||
| 			#if self.link_type != link_types.pointer: | 			#if self.link_type != link_types.pointer: | ||||||
| 			text += "\n\t\tstatic " + self.name + "* get_py_obj(" + long_name + "* ref)\n\t\t{" | 			text += "\n\t\tstatic " + self.name + "* get_py_obj(" + long_name + "* ref)\n\t\t{" | ||||||
|  | 			text += "\n\t\t\tif(ref == nullptr){" | ||||||
|  | 			text += "\n\t\t\t\tthrow std::runtime_error(\"" + self.name + " does not exist.\");" | ||||||
|  | 			text += "\n\t\t\t}" | ||||||
| 			text += "\n\t\t\t" + self.name + "* ret = (" + self.name + "*)malloc(sizeof(" + self.name + "));" | 			text += "\n\t\t\t" + self.name + "* ret = (" + self.name + "*)malloc(sizeof(" + self.name + "));" | ||||||
| 			if self.link_type == link_types.pointer: | 			if self.link_type == link_types.pointer: | ||||||
| 				text += "\n\t\t\tret->ref_obj = ref;" | 				text += "\n\t\t\tret->ref_obj = ref;" | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue