diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c index cee447bfc6..61120fae52 100644 --- a/Modules/_bsddb.c +++ b/Modules/_bsddb.c @@ -6696,21 +6696,29 @@ DBEnv_log_file(DBEnvObject* self, PyObject* args) if (err == EINVAL) { free(name); size *= 2; + if (size>=(1<<17)) { + /* + ** the final buffer we try is too small, we will + ** get this exception: + ** DBInvalidArgError: + ** (22, 'Invalid argument -- DB_ENV->log_file: name buffer is too short') + */ + RETURN_IF_ERR(); + assert(0); /* Unreachable... supposely */ + return NULL; + } + // go through the loop again, trying a bigger buffer } else if (err) { free(name); RETURN_IF_ERR(); assert(0); /* Unreachable... supposely */ return NULL; + } else { + // everything is fine + break; } -/* -** If the final buffer we try is too small, we will -** get this exception: -** DBInvalidArgError: -** (22, 'Invalid argument -- DB_ENV->log_file: name buffer is too short') -*/ - } while ((err == EINVAL) && (size<(1<<17))); - RETURN_IF_ERR(); /* Maybe the size is not the problem */ + } while (1); retval = Py_BuildValue("s", name); free(name);