crash in libsoup when log level is SOUP_LOGGER_LOG_BODY
I have used following code in my code:
SoupLogger *logger;
logger = soup_logger_new (SOUP_LOGGER_LOG_BODY);
soup_session_add_feature(m_soupSession.get(), SOUP_SESSION_FEATURE(logger));
g_object_unref (logger);
soup_session_add_feature_by_type(m_soupSession.get(), SOUP_TYPE_CONTENT_SNIFFER);
and when running the code, I found a warning reported:
invalid cast from 'SoupLoggerInputStream' to 'SoupContentSnifferStream'
, it's reported in below code when converting stream to sniffer:
static gssize
read_and_sniff (GInputStream *stream, gboolean blocking,
GCancellable *cancellable, GError **error)
{
SoupContentSnifferStream *sniffer = SOUP_CONTENT_SNIFFER_STREAM (stream);
SoupContentSnifferStreamPrivate *priv = soup_content_sniffer_stream_get_instance_private (sniffer);
and later, the priv
pointer has a member priv->buffer_nread
with value -1431655766
, and the libsoup crashed later when trying to memcpy
content to the address: priv->buffer + priv->buffer_nread
.
If I only enable the libsoup log level to 'SOUP_LOGGER_LOG_HEADERS', then no crash happened. Could you please help check what caused the invalid cast? Thanks.
Edited by Andre Klapper