~pythonregexp2.7/python/issue2636-01+09-01-01

« back to all changes in this revision

Viewing changes to Objects/bufferobject.c

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-09-22 00:02:12 UTC
  • mfrom: (39022.1.34 Regexp-2.7)
  • Revision ID: darklord@timehorse.com-20080922000212-7r0q4f4ugiq57jph
Merged in changes from the Atomic Grouping / Possessive Qualifiers branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
207
207
                                "size must be zero or positive");
208
208
                return NULL;
209
209
        }
210
 
        /* XXX: check for overflow in multiply */
 
210
        if (sizeof(*b) > PY_SSIZE_T_MAX - size) {
 
211
                /* unlikely */
 
212
                return PyErr_NoMemory();
 
213
        }
211
214
        /* Inline PyObject_New */
212
215
        o = (PyObject *)PyObject_MALLOC(sizeof(*b) + size);
213
216
        if ( o == NULL )
233
236
        Py_ssize_t offset = 0;
234
237
        Py_ssize_t size = Py_END_OF_BUFFER;
235
238
 
236
 
        if (PyErr_WarnPy3k("buffer() not supported in 3.x; "
237
 
                         "use memoryview()", 1) < 0)
 
239
        if (PyErr_WarnPy3k("buffer() not supported in 3.x", 1) < 0)
238
240
                return NULL;
239
241
        
240
242
        if (!_PyArg_NoKeywords("buffer()", kw))
401
403
        if ( (count = (*pb->bf_getreadbuffer)(other, 0, &ptr2)) < 0 )
402
404
                return NULL;
403
405
 
 
406
        assert(count <= PY_SIZE_MAX - size);
 
407
 
404
408
        ob = PyString_FromStringAndSize(NULL, size + count);
405
409
        if ( ob == NULL )
406
410
                return NULL;
426
430
                count = 0;
427
431
        if (!get_buf(self, &ptr, &size, ANY_BUFFER))
428
432
                return NULL;
 
433
        if (count > PY_SSIZE_T_MAX / size) {
 
434
                PyErr_SetString(PyExc_MemoryError, "result too large");
 
435
                return NULL;
 
436
        }
429
437
        ob = PyString_FromStringAndSize(NULL, size * count);
430
438
        if ( ob == NULL )
431
439
                return NULL;