mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 11:49:12 +00:00 
			
		
		
		
	reset errno before calling confstr - use confstr() doc to simplify checks afterwards
This commit is contained in:
		
							parent
							
								
									429433b30b
								
							
						
					
					
						commit
						dd527fcbcd
					
				
					 1 changed files with 9 additions and 7 deletions
				
			
		| 
						 | 
					@ -6812,17 +6812,19 @@ posix_confstr(PyObject *self, PyObject *args)
 | 
				
			||||||
    char buffer[64];
 | 
					    char buffer[64];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (PyArg_ParseTuple(args, "O&:confstr", conv_confstr_confname, &name)) {
 | 
					    if (PyArg_ParseTuple(args, "O&:confstr", conv_confstr_confname, &name)) {
 | 
				
			||||||
        int len = confstr(name, buffer, sizeof(buffer));
 | 
						int len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        errno = 0;
 | 
					        errno = 0;
 | 
				
			||||||
        if (len == 0) {
 | 
						len = confstr(name, buffer, sizeof(buffer));
 | 
				
			||||||
            if (errno != 0)
 | 
					
 | 
				
			||||||
 | 
						if (len == -1) {
 | 
				
			||||||
	    posix_error();
 | 
						    posix_error();
 | 
				
			||||||
            else
 | 
						}
 | 
				
			||||||
 | 
						else if (len == 0) {
 | 
				
			||||||
            result = PyString_FromString("");
 | 
					            result = PyString_FromString("");
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else {
 | 
					        else {
 | 
				
			||||||
            if (len >= sizeof(buffer)) {
 | 
							if ((unsigned int)len >= sizeof(buffer)) {
 | 
				
			||||||
                result = PyString_FromStringAndSize(NULL, len);
 | 
					                result = PyString_FromStringAndSize(NULL, len);
 | 
				
			||||||
                if (result != NULL)
 | 
					                if (result != NULL)
 | 
				
			||||||
                    confstr(name, PyString_AS_STRING(result), len+1);
 | 
					                    confstr(name, PyString_AS_STRING(result), len+1);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue