| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -132,18 +132,26 @@ int pysqlite_statement_bind_parameter(pysqlite_Statement* self, int pos, PyObjec | |||
| 132 | 132 | break; | |
| 133 | 133 | case TYPE_UNICODE: | |
| 134 | 134 | string = _PyUnicode_AsStringAndSize(parameter, &buflen); | |
| 135 | - if (string != NULL) | ||
| 136 | - rc = sqlite3_bind_text(self->st, pos, string, buflen, SQLITE_TRANSIENT); | ||
| 137 | - else | ||
| 138 | - rc = -1; | ||
| 135 | + if (string == NULL) | ||
| 136 | + return -1; | ||
| 137 | + if (buflen > INT_MAX) { | ||
| 138 | + PyErr_SetString(PyExc_OverflowError, | ||
| 139 | + "string longer than INT_MAX bytes"); | ||
| 140 | + return -1; | ||
| 141 | + } | ||
| 142 | + rc = sqlite3_bind_text(self->st, pos, string, (int)buflen, SQLITE_TRANSIENT); | ||
| 139 | 143 | break; | |
| 140 | 144 | case TYPE_BUFFER: | |
| 141 | - if (PyObject_AsCharBuffer(parameter, &buffer, &buflen) == 0) { | ||
| 142 | - rc = sqlite3_bind_blob(self->st, pos, buffer, buflen, SQLITE_TRANSIENT); | ||
| 143 | - } else { | ||
| 145 | + if (PyObject_AsCharBuffer(parameter, &buffer, &buflen) != 0) { | ||
| 144 | 146 | PyErr_SetString(PyExc_ValueError, "could not convert BLOB to buffer"); | |
| 145 | - rc = -1; | ||
| 147 | + return -1; | ||
| 148 | + } | ||
| 149 | + if (buflen > INT_MAX) { | ||
| 150 | + PyErr_SetString(PyExc_OverflowError, | ||
| 151 | + "BLOB longer than INT_MAX bytes"); | ||
| 152 | + return -1; | ||
| 146 | 153 | } | |
| 154 | + rc = sqlite3_bind_blob(self->st, pos, buffer, buflen, SQLITE_TRANSIENT); | ||
| 147 | 155 | break; | |
| 148 | 156 | case TYPE_UNKNOWN: | |
| 149 | 157 | rc = -1; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments