mirror of
				https://github.com/psycopg/psycopg2.git
				synced 2025-11-04 01:37:31 +03:00 
			
		
		
		
	Fix memory leak in conn_set_client_encoding
If the specified encoding is the same as the current one, the early exit did not release the clean_enc string allocated by clear_encoding_name.
This commit is contained in:
		
							parent
							
								
									8b2450287e
								
							
						
					
					
						commit
						364b0e0563
					
				| 
						 | 
					@ -1389,7 +1389,10 @@ conn_set_client_encoding(connectionObject *self, const char *pgenc)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* If the current encoding is equal to the requested one we don't
 | 
					    /* If the current encoding is equal to the requested one we don't
 | 
				
			||||||
       issue any query to the backend */
 | 
					       issue any query to the backend */
 | 
				
			||||||
    if (strcmp(self->encoding, clean_enc) == 0) return 0;
 | 
					    if (strcmp(self->encoding, clean_enc) == 0) {
 | 
				
			||||||
 | 
					        res = 0;
 | 
				
			||||||
 | 
					        goto exit;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Py_BEGIN_ALLOW_THREADS;
 | 
					    Py_BEGIN_ALLOW_THREADS;
 | 
				
			||||||
    pthread_mutex_lock(&self->lock);
 | 
					    pthread_mutex_lock(&self->lock);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user