/* Looking for BOM. */
- if (!data->ignore_bom) {
+ if (start != NULL && !data->ignore_bom) {
start += njs_utf8_bom(start, end);
}
size = 0;
length = 0;
- end = p + len;
+ if (p != NULL) {
+ end = p + len;
- while (p < end) {
- codepoint = njs_utf8_decode(ctx, &p, end);
+ while (p < end) {
+ codepoint = njs_utf8_decode(ctx, &p, end);
- if (codepoint > NJS_UNICODE_MAX_CODEPOINT) {
- if (codepoint == NJS_UNICODE_CONTINUE) {
- break;
- }
+ if (codepoint > NJS_UNICODE_MAX_CODEPOINT) {
+ if (codepoint == NJS_UNICODE_CONTINUE) {
+ break;
+ }
- if (fatal) {
- return -1;
+ if (fatal) {
+ return -1;
+ }
+
+ codepoint = NJS_UNICODE_REPLACEMENT;
}
- codepoint = NJS_UNICODE_REPLACEMENT;
+ size += njs_utf8_size(codepoint);
+ length++;
}
-
- size += njs_utf8_size(codepoint);
- length++;
}
if (last && ctx->need != 0x00) {