core: stringstream: fix internal buffer not always being null-terminated
This commit is contained in:
+7
-3
@@ -84,6 +84,7 @@ static enum fx_status __puts(
|
||||
}
|
||||
|
||||
memcpy(ss->ss_buf + ss->ss_len, s, to_copy);
|
||||
ss->ss_buf[ss->ss_len + to_copy] = 0;
|
||||
|
||||
/* increment the length by the full string length, even if only a
|
||||
* portion was copied */
|
||||
@@ -154,7 +155,8 @@ fx_stringstream *fx_stringstream_create_with_buffer(char *buf, size_t max)
|
||||
}
|
||||
|
||||
fx_stream_cfg *cfg = fx_object_get_protected(s, FX_TYPE_STREAM);
|
||||
struct fx_stringstream_p *p = fx_object_get_private(s, FX_TYPE_STRINGSTREAM);
|
||||
struct fx_stringstream_p *p
|
||||
= fx_object_get_private(s, FX_TYPE_STRINGSTREAM);
|
||||
|
||||
cfg->s_mode = FX_STREAM_READ | FX_STREAM_WRITE | Z__FX_STREAM_STATIC;
|
||||
|
||||
@@ -174,7 +176,8 @@ fx_stringstream *fx_stringstream_create(void)
|
||||
}
|
||||
|
||||
fx_stream_cfg *cfg = fx_object_get_protected(s, FX_TYPE_STREAM);
|
||||
struct fx_stringstream_p *p = fx_object_get_private(s, FX_TYPE_STRINGSTREAM);
|
||||
struct fx_stringstream_p *p
|
||||
= fx_object_get_private(s, FX_TYPE_STRINGSTREAM);
|
||||
|
||||
cfg->s_mode = FX_STREAM_READ | FX_STREAM_WRITE | Z__FX_STREAM_STATIC;
|
||||
|
||||
@@ -248,7 +251,8 @@ enum fx_status stream_getc(fx_stream *stream, fx_wchar *c)
|
||||
return status;
|
||||
}
|
||||
|
||||
enum fx_status stream_read(fx_stream *stream, void *buf, size_t count, size_t *nr_read)
|
||||
enum fx_status stream_read(
|
||||
fx_stream *stream, void *buf, size_t count, size_t *nr_read)
|
||||
{
|
||||
struct fx_stringstream_p *s
|
||||
= fx_object_get_private(stream, FX_TYPE_STRINGSTREAM);
|
||||
|
||||
Reference in New Issue
Block a user