Skip to content
Myr

Fix jv_load_file() assertion (fix #1410)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Nicolas Williams · committed by Nicolas Williams · parent cb3d5af · Browse files · 2 files+7 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+7 added−5 removed

  • other:+7 added−5 removed

2 files+7 added−5 removed

modified:src/jv_file.c+6 added-4 removed
28 unmodified lines
29 char buf[4096+max_utf8_len];30 while (!feof(file) && !ferror(file)) {31 size_t n = fread(buf, 1, sizeof(buf)-max_utf8_len, file);32 int len = 0;33 if (jvp_utf8_backtrack(buf+(n-1), buf, &len) && len > 0) {34 if (!feof(file) && !ferror(file)) {35 n += fread(buf+n, 1, len, file);36 }3334 if (n == 0)35 continue;36 if (jvp_utf8_backtrack(buf+(n-1), buf, &len) && len > 0 &&37 !feof(file) && !ferror(file)) {38 n += fread(buf+n, 1, len, file);39 }4041 if (raw) {42 data = jv_string_append_buf(data, buf, n);
22 unmodified lines
modified:src/jv_unicode.c+1 added-1 removed
7 unmodified lines
8// If the last codepoint is incomplete, returns the number of missing bytes via9// *missing_bytes. If there are no leading bytes or an invalid byte is10// encountered, NULL is returned and *missing_bytes is not altered.11const char* jvp_utf8_backtrack(const char* start, const char* min, int *missing_bytes) {12 assert(min < start);12 assert(min <= start);13 if (min == start) {14 return min;15 }16 int length = 0;
104 unmodified lines