Fix segfault when destroying mu_body_t under certain conditions
That's a temporary solution until reference counters are implemented for mu_body_t * libmailutils/mailbox/body.c (bstr_close, bstr_done): Don't close streams.
Showing
1 changed file
with
11 additions
and
0 deletions
... | @@ -116,20 +116,31 @@ body_stream_transport (mu_stream_t stream, int mode, mu_stream_t *pstr) | ... | @@ -116,20 +116,31 @@ body_stream_transport (mu_stream_t stream, int mode, mu_stream_t *pstr) |
116 | static int | 116 | static int |
117 | bstr_close (struct _mu_stream *stream) | 117 | bstr_close (struct _mu_stream *stream) |
118 | { | 118 | { |
119 | /* FIXME: While technically correct, the code below can result is | ||
120 | segmentation violations under some conditions, because reference | ||
121 | counters are not yet implemented for mu_body_t objects and so | ||
122 | str->body can be destroyed prior to calling that function. | ||
123 | See also bstr_done. | ||
124 | */ | ||
125 | #if 0 | ||
119 | struct _mu_body_stream *str = (struct _mu_body_stream*) stream; | 126 | struct _mu_body_stream *str = (struct _mu_body_stream*) stream; |
120 | mu_body_t body = str->body; | 127 | mu_body_t body = str->body; |
121 | mu_stream_close (body->rawstream); | 128 | mu_stream_close (body->rawstream); |
122 | mu_stream_close (body->fstream); | 129 | mu_stream_close (body->fstream); |
130 | #endif | ||
123 | return 0; | 131 | return 0; |
124 | } | 132 | } |
125 | 133 | ||
126 | void | 134 | void |
127 | bstr_done (struct _mu_stream *stream) | 135 | bstr_done (struct _mu_stream *stream) |
128 | { | 136 | { |
137 | #if 0 | ||
138 | /* FIXME: See comment above */ | ||
129 | struct _mu_body_stream *str = (struct _mu_body_stream*) stream; | 139 | struct _mu_body_stream *str = (struct _mu_body_stream*) stream; |
130 | mu_body_t body = str->body; | 140 | mu_body_t body = str->body; |
131 | mu_stream_destroy (&body->rawstream); | 141 | mu_stream_destroy (&body->rawstream); |
132 | mu_stream_destroy (&body->fstream); | 142 | mu_stream_destroy (&body->fstream); |
143 | #endif | ||
133 | } | 144 | } |
134 | 145 | ||
135 | static int | 146 | static int | ... | ... |
-
Please register or sign in to post a comment