mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Handle more memory allocation failures without crashing.
This commit is contained in:
		
							parent
							
								
									33722aec57
								
							
						
					
					
						commit
						d12bd012a6
					
				
					 5 changed files with 38 additions and 8 deletions
				
			
		|  | @ -221,8 +221,12 @@ PySymtable_Build(mod_ty mod, const char *filename, PyFutureFeatures *future) | |||
| 		return st; | ||||
| 	st->st_filename = filename; | ||||
| 	st->st_future = future; | ||||
| 	symtable_enter_block(st, GET_IDENTIFIER(top), ModuleBlock,  | ||||
| 			     (void *)mod, 0); | ||||
| 	if (!symtable_enter_block(st, GET_IDENTIFIER(top), ModuleBlock,  | ||||
| 			     (void *)mod, 0)) { | ||||
| 		PySymtable_Free(st); | ||||
| 		return NULL; | ||||
| 	} | ||||
| 
 | ||||
| 	st->st_top = st->st_cur; | ||||
| 	st->st_cur->ste_unoptimized = OPT_TOPLEVEL; | ||||
| 	/* Any other top-level initialization? */ | ||||
|  | @ -728,6 +732,8 @@ symtable_exit_block(struct symtable *st, void *ast) | |||
| 	if (end >= 0) { | ||||
| 		st->st_cur = (PySTEntryObject *)PyList_GET_ITEM(st->st_stack,  | ||||
| 								end); | ||||
| 		if (st->st_cur == NULL) | ||||
| 			return 0; | ||||
| 		Py_INCREF(st->st_cur); | ||||
| 		if (PySequence_DelItem(st->st_stack, end) < 0) | ||||
| 			return 0; | ||||
|  | @ -749,6 +755,8 @@ symtable_enter_block(struct symtable *st, identifier name, _Py_block_ty block, | |||
| 		Py_DECREF(st->st_cur); | ||||
| 	} | ||||
| 	st->st_cur = PySTEntry_New(st, name, block, ast, lineno); | ||||
| 	if (st->st_cur == NULL) | ||||
| 		return 0; | ||||
| 	if (name == GET_IDENTIFIER(top)) | ||||
| 		st->st_global = st->st_cur->ste_symbols; | ||||
| 	if (prev) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Neal Norwitz
						Neal Norwitz