mirror of
https://github.com/mpv-player/mpv.git
synced 2024-09-20 12:02:23 +02:00
Add asserts to detect when assumptions for play_tree_parser_get_line
fail (mostly due to parsers using it incorrectly). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@28217 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
a2c2268cdf
commit
27fcc9c6a6
@ -6,9 +6,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef MP_DEBUG
|
||||
#include <assert.h>
|
||||
#endif
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@ -61,6 +59,8 @@ play_tree_parser_get_line(play_tree_parser_t* p) {
|
||||
if(p->stream->eof && (p->buffer_end == 0 || p->iter[0] == '\0'))
|
||||
return NULL;
|
||||
|
||||
assert(p->buffer_end < p->buffer_size);
|
||||
assert(!p->buffer[p->buffer_end]);
|
||||
while(1) {
|
||||
|
||||
if(resize) {
|
||||
@ -75,10 +75,12 @@ play_tree_parser_get_line(play_tree_parser_t* p) {
|
||||
r = stream_read(p->stream,p->buffer + p->buffer_end,p->buffer_size - p->buffer_end - 1);
|
||||
if(r > 0) {
|
||||
p->buffer_end += r;
|
||||
assert(p->buffer_end < p->buffer_size);
|
||||
p->buffer[p->buffer_end] = '\0';
|
||||
while(strlen(p->buffer + p->buffer_end - r) != r)
|
||||
p->buffer[p->buffer_end - r + strlen(p->buffer + p->buffer_end - r)] = '\n';
|
||||
}
|
||||
assert(!p->buffer[p->buffer_end]);
|
||||
}
|
||||
|
||||
end = strchr(p->iter,'\n');
|
||||
|
Loading…
Reference in New Issue
Block a user