mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	Issue #15381: Try to fix refcount bug. Empty and 1-byte buffers are always shared.
This commit is contained in:
		
							parent
							
								
									ab53ab0a84
								
							
						
					
					
						commit
						b9765eec5c
					
				
					 1 changed files with 3 additions and 1 deletions
				
			
		| 
						 | 
					@ -38,7 +38,8 @@ typedef struct {
 | 
				
			||||||
        return NULL; \
 | 
					        return NULL; \
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define SHARED_BUF(self) (Py_REFCNT((self)->buf) > 1)
 | 
					#define SHARED_BUF(self) (Py_REFCNT((self)->buf) > 1 || \
 | 
				
			||||||
 | 
					                          PyBytes_GET_SIZE((self)->buf) <= 1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Internal routine to get a line from the buffer of a BytesIO
 | 
					/* Internal routine to get a line from the buffer of a BytesIO
 | 
				
			||||||
| 
						 | 
					@ -308,6 +309,7 @@ read_bytes(bytesio *self, Py_ssize_t size)
 | 
				
			||||||
    char *output;
 | 
					    char *output;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    assert(self->buf != NULL);
 | 
					    assert(self->buf != NULL);
 | 
				
			||||||
 | 
					    assert(size <= self->string_size);
 | 
				
			||||||
    if (size > 1 &&
 | 
					    if (size > 1 &&
 | 
				
			||||||
        self->pos == 0 && size == PyBytes_GET_SIZE(self->buf) &&
 | 
					        self->pos == 0 && size == PyBytes_GET_SIZE(self->buf) &&
 | 
				
			||||||
        self->exports == 0) {
 | 
					        self->exports == 0) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue