(internal_icvt_read,copy_octal): Fixed memory allocation errors.
Showing
1 changed file
with
6 additions
and
2 deletions
... | @@ -204,6 +204,7 @@ internal_icvt_read (stream_t stream, char *optr, size_t osize, size_t *pnbytes) | ... | @@ -204,6 +204,7 @@ internal_icvt_read (stream_t stream, char *optr, size_t osize, size_t *pnbytes) |
204 | char *p = realloc (s->buf, s->bufsize + 128); | 204 | char *p = realloc (s->buf, s->bufsize + 128); |
205 | if (!p) | 205 | if (!p) |
206 | return ENOMEM; | 206 | return ENOMEM; |
207 | s->buf = p; | ||
207 | s->bufsize += 128; | 208 | s->bufsize += 128; |
208 | } | 209 | } |
209 | continue; | 210 | continue; |
... | @@ -255,7 +256,10 @@ copy_octal (struct icvt_stream *s, char *optr, size_t osize, size_t *pnbytes) | ... | @@ -255,7 +256,10 @@ copy_octal (struct icvt_stream *s, char *optr, size_t osize, size_t *pnbytes) |
255 | /* Try to reallocate temp buffer */ | 256 | /* Try to reallocate temp buffer */ |
256 | char *p = realloc (s->buf, rdcount); | 257 | char *p = realloc (s->buf, rdcount); |
257 | if (p) | 258 | if (p) |
258 | s->bufsize = rdcount; | 259 | { |
260 | s->bufsize = rdcount; | ||
261 | s->buf = p; | ||
262 | } | ||
259 | else | 263 | else |
260 | rdcount = s->bufsize; | 264 | rdcount = s->bufsize; |
261 | } | 265 | } |
... | @@ -279,7 +283,7 @@ copy_octal (struct icvt_stream *s, char *optr, size_t osize, size_t *pnbytes) | ... | @@ -279,7 +283,7 @@ copy_octal (struct icvt_stream *s, char *optr, size_t osize, size_t *pnbytes) |
279 | { | 283 | { |
280 | if (ISPRINT (*(unsigned char*)(s->buf+i))) | 284 | if (ISPRINT (*(unsigned char*)(s->buf+i))) |
281 | optr[j++] = s->buf[i]; | 285 | optr[j++] = s->buf[i]; |
282 | else if (j + 4 >= s->bufpos) | 286 | else if (j + 4 >= osize) |
283 | break; | 287 | break; |
284 | else | 288 | else |
285 | { | 289 | { | ... | ... |
-
Please register or sign in to post a comment