mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	Plug a memory leak in Py_InitModule4(): when PyDict_SetItemString() failed,
the object being inserted was not being DECREFed. This closes SF bug #444486.
This commit is contained in:
		
							parent
							
								
									53765753c4
								
							
						
					
					
						commit
						289898cdbb
					
				
					 1 changed files with 6 additions and 2 deletions
				
			
		|  | @ -60,14 +60,18 @@ Py_InitModule4(char *name, PyMethodDef *methods, char *doc, | |||
| 		v = PyCFunction_New(ml, passthrough); | ||||
| 		if (v == NULL) | ||||
| 			return NULL; | ||||
| 		if (PyDict_SetItemString(d, ml->ml_name, v) != 0) | ||||
| 		if (PyDict_SetItemString(d, ml->ml_name, v) != 0) { | ||||
| 			Py_DECREF(v); | ||||
| 			return NULL; | ||||
| 		} | ||||
| 		Py_DECREF(v); | ||||
| 	} | ||||
| 	if (doc != NULL) { | ||||
| 		v = PyString_FromString(doc); | ||||
| 		if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0) | ||||
| 		if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0) { | ||||
| 			Py_DECREF(v); | ||||
| 			return NULL; | ||||
| 		} | ||||
| 		Py_DECREF(v); | ||||
| 	} | ||||
| 	return m; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Fred Drake
						Fred Drake