Return empty string when buffer is closed or unallocated
This should be refactored later, just do defensive programming for now.
@@ -446,6 +446,10 @@ static PHP_METHOD(Swow_WebSocket_Frame, getPayloadDataAsString)
payload_data = swow_buffer_get_string(swow_buffer_get_from_object(sframe->payload_data));
+ if (payload_data == NULL) {
+ RETURN_EMPTY_STRING();
+ }
+
/* Notice: string maybe interned, so we must use zend_string_copy() here */
RETURN_STR(zend_string_copy(payload_data));
}
