]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-115026: Argument Clinic: handle PyBuffer_FillInfo errors in generated code (#115027)
authorNikita Sobolev <mail@sobolevn.me>
Mon, 5 Feb 2024 10:45:09 +0000 (13:45 +0300)
committerGitHub <noreply@github.com>
Mon, 5 Feb 2024 10:45:09 +0000 (11:45 +0100)
Modules/_sqlite/clinic/connection.c.h
Modules/clinic/_codecsmodule.c.h
Modules/clinic/_ssl.c.h
Tools/clinic/clinic.py

index db5eb77891e52e53cf38b54980cc0527381501ab..f2cff6a7b421f3b5bb78b80b53cb45678d5b1c54 100644 (file)
@@ -1551,7 +1551,9 @@ deserialize(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs,
         if (ptr == NULL) {
             goto exit;
         }
-        PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0);
+        if (PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, PyBUF_SIMPLE) < 0) {
+            goto exit;
+        }
     }
     else { /* any bytes-like object */
         if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
@@ -1818,4 +1820,4 @@ exit:
 #ifndef DESERIALIZE_METHODDEF
     #define DESERIALIZE_METHODDEF
 #endif /* !defined(DESERIALIZE_METHODDEF) */
-/*[clinic end generated code: output=90b5b9c14261b8d7 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=99299d3ee2c247ab input=a9049054013a1b77]*/
index 12fea806ab52093bf9bcfb71d73f60a8c916c36c..1c0f37442ab3509a479455a9932d3a592a3308b5 100644 (file)
@@ -297,7 +297,9 @@ _codecs_escape_decode(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
         if (ptr == NULL) {
             goto exit;
         }
-        PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0);
+        if (PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, PyBUF_SIMPLE) < 0) {
+            goto exit;
+        }
     }
     else { /* any bytes-like object */
         if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
@@ -1099,7 +1101,9 @@ _codecs_unicode_escape_decode(PyObject *module, PyObject *const *args, Py_ssize_
         if (ptr == NULL) {
             goto exit;
         }
-        PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0);
+        if (PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, PyBUF_SIMPLE) < 0) {
+            goto exit;
+        }
     }
     else { /* any bytes-like object */
         if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
@@ -1175,7 +1179,9 @@ _codecs_raw_unicode_escape_decode(PyObject *module, PyObject *const *args, Py_ss
         if (ptr == NULL) {
             goto exit;
         }
-        PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0);
+        if (PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, PyBUF_SIMPLE) < 0) {
+            goto exit;
+        }
     }
     else { /* any bytes-like object */
         if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
@@ -1644,7 +1650,9 @@ _codecs_readbuffer_encode(PyObject *module, PyObject *const *args, Py_ssize_t na
         if (ptr == NULL) {
             goto exit;
         }
-        PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0);
+        if (PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, PyBUF_SIMPLE) < 0) {
+            goto exit;
+        }
     }
     else { /* any bytes-like object */
         if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
@@ -2738,4 +2746,4 @@ exit:
 #ifndef _CODECS_CODE_PAGE_ENCODE_METHODDEF
     #define _CODECS_CODE_PAGE_ENCODE_METHODDEF
 #endif /* !defined(_CODECS_CODE_PAGE_ENCODE_METHODDEF) */
-/*[clinic end generated code: output=d8d9e372f7ccba35 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=e50d5fdf65bd45fa input=a9049054013a1b77]*/
index 19c0f619b92f45c4d2968ac8837bffc8c1b839d6..2940f16a2cb7f6a140198bdcf5df8e548d53c3d0 100644 (file)
@@ -1297,7 +1297,9 @@ _ssl_RAND_add(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
         if (ptr == NULL) {
             goto exit;
         }
-        PyBuffer_FillInfo(&view, args[0], (void *)ptr, len, 1, 0);
+        if (PyBuffer_FillInfo(&view, args[0], (void *)ptr, len, 1, PyBUF_SIMPLE) < 0) {
+            goto exit;
+        }
     }
     else { /* any bytes-like object */
         if (PyObject_GetBuffer(args[0], &view, PyBUF_SIMPLE) != 0) {
@@ -1662,4 +1664,4 @@ exit:
 #ifndef _SSL_ENUM_CRLS_METHODDEF
     #define _SSL_ENUM_CRLS_METHODDEF
 #endif /* !defined(_SSL_ENUM_CRLS_METHODDEF) */
-/*[clinic end generated code: output=6342ea0062ab16c7 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=fd1c3378fbba5240 input=a9049054013a1b77]*/
index 770878a3f8d2c780752275eb743442e6b93f5b7b..c1df83a72bd8ceaab4fcef9df7f4a0ce8c8e7458 100755 (executable)
@@ -4368,7 +4368,9 @@ class Py_buffer_converter(CConverter):
                     if (ptr == NULL) {{{{
                         goto exit;
                     }}}}
-                    PyBuffer_FillInfo(&{paramname}, {argname}, (void *)ptr, len, 1, 0);
+                    if (PyBuffer_FillInfo(&{paramname}, {argname}, (void *)ptr, len, 1, PyBUF_SIMPLE) < 0) {{{{
+                        goto exit;
+                    }}}}
                 }}}}
                 else {{{{ /* any bytes-like object */
                     if (PyObject_GetBuffer({argname}, &{paramname}, PyBUF_SIMPLE) != 0) {{{{