diff --git a/mozilla/extensions/python/xpcom/src/PyIInputStream.cpp b/mozilla/extensions/python/xpcom/src/PyIInputStream.cpp index a374b74470e..482550cee99 100644 --- a/mozilla/extensions/python/xpcom/src/PyIInputStream.cpp +++ b/mozilla/extensions/python/xpcom/src/PyIInputStream.cpp @@ -80,6 +80,9 @@ static PyObject *DoPyRead_Size(nsIInputStream *pI, PRUint32 n) if (NS_FAILED(r)) return PyXPCOM_BuildPyException(r); } + if (n==0) { // mozilla will assert if we alloc zero bytes. + return PyBuffer_New(0); + } char *buf = (char *)nsMemory::Alloc(n); if (buf==NULL) { PyErr_NoMemory(); diff --git a/mozilla/extensions/python/xpcom/src/VariantUtils.cpp b/mozilla/extensions/python/xpcom/src/VariantUtils.cpp index 20a4becf456..4454e8db37e 100644 --- a/mozilla/extensions/python/xpcom/src/VariantUtils.cpp +++ b/mozilla/extensions/python/xpcom/src/VariantUtils.cpp @@ -2482,6 +2482,7 @@ nsresult PyXPCOM_GatewayVariantHelper::BackFillVariant( PyObject *val, int index if (val == Py_None) break; // Remains NULL. size_t nbytes = sequence_size * element_size; + if (nbytes==0) nbytes = 1; // avoid assertion about 0 bytes *pp = (void *)nsMemory::Alloc(nbytes); memset(*pp, 0, nbytes); rc = FillSingleArray(*pp, val, sequence_size, element_size, array_type&XPT_TDP_TAGMASK);