diff options
author | Dave Beckett <dave@dajobe.org> | 2012-05-16 20:14:30 -0700 |
---|---|---|
committer | Dave Beckett <dave@dajobe.org> | 2012-05-16 20:14:30 -0700 |
commit | 5b64b284cb0a56ce20763668fb5b982fbdca22d4 (patch) | |
tree | d611d782e5ac14c127df81a23f84e4ff8ca4c6a9 /src/ntriples_parse.c | |
parent | e3b5ae608542376435c05c7011fbb79007212b59 (diff) | |
download | raptor-5b64b284cb0a56ce20763668fb5b982fbdca22d4.tar.gz |
Handle errors from raptor_unicode_utf8_string_put_char
(raptor_stringbuffer_append_turtle_string,
raptor_string_python_write, raptor_ntriples_term): Store result in
int and only use it if positive.
Part of fix for
Issue #0000505
http://bugs.librdf.org/mantis/view.php?id=505
Diffstat (limited to 'src/ntriples_parse.c')
-rw-r--r-- | src/ntriples_parse.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ntriples_parse.c b/src/ntriples_parse.c index c6b4b9fb..3c2edc6f 100644 --- a/src/ntriples_parse.c +++ b/src/ntriples_parse.c @@ -369,6 +369,8 @@ raptor_ntriples_term(raptor_parser* rdf_parser, /* find end of string, fixing backslashed characters on the way */ while(*lenp > 0) { + int unichar_width; + c = *p; p++; @@ -491,13 +493,21 @@ raptor_ntriples_term(raptor_parser* rdf_parser, break; } + unichar_width = raptor_unicode_utf8_string_put_char(unichar, dest, 4); + if(unichar_width < 0) { + raptor_parser_error(rdf_parser, + "Illegal Unicode character with code point #x%lX.", + unichar); + break; + } + /* The destination length is set here to 4 since we know that in * all cases, the UTF-8 encoded output sequence is always shorter * than the input sequence, and the buffer is edited in place. * \uXXXX: 6 bytes input - UTF-8 max 3 bytes output * \uXXXXXXXX: 10 bytes input - UTF-8 max 4 bytes output */ - dest += raptor_unicode_utf8_string_put_char(unichar, dest, 4); + dest += (int)unichar_width; break; default: |