lib_syslograwstream: fix bug when iob alloc failed

Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
This commit is contained in:
Bowen Wang 2023-06-14 14:08:40 +08:00 committed by Xiang Xiao
parent 7117d3ea8a
commit 8515294caa
2 changed files with 7 additions and 2 deletions

View File

@ -255,10 +255,10 @@ struct lib_syslograwstream_s
# else # else
char buffer[CONFIG_SYSLOG_BUFSIZE]; char buffer[CONFIG_SYSLOG_BUFSIZE];
# endif # endif
#endif
FAR char *base; FAR char *base;
int size; int size;
int offset; int offset;
#endif
int last_ch; int last_ch;
}; };

View File

@ -288,14 +288,19 @@ void lib_syslograwstream_open(FAR struct lib_syslograwstream_s *stream)
stream->base = (FAR void *)stream->iob->io_data; stream->base = (FAR void *)stream->iob->io_data;
stream->size = sizeof(stream->iob->io_data); stream->size = sizeof(stream->iob->io_data);
} }
else
{
stream->base = NULL;
stream->size = 0;
}
# else # else
stream->base = stream->buffer; stream->base = stream->buffer;
stream->size = sizeof(stream->buffer); stream->size = sizeof(stream->buffer);
# endif # endif
stream->offset = 0;
#else #else
stream->public.flush = lib_noflush; stream->public.flush = lib_noflush;
#endif #endif
stream->offset = 0;
} }
/**************************************************************************** /****************************************************************************