diff --git a/DESCRIPTION b/DESCRIPTION index 45d1bb0..f729685 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: yyjsonr Type: Package Title: Fast JSON Parser and Generator -Version: 0.1.17 +Version: 0.1.17.9000 Authors@R: c( person("Mike", "Cheng", role = c("aut", "cre", 'cph'), email = "mikefc@coolbutuseless.com"), diff --git a/NEWS.md b/NEWS.md index deafc8f..3e3774a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,11 @@ + +# yyjsonr 0.1.18 2024-01-22 + +* Fixes for CRAN + * Adjust pointer arithmetic when calling `output_verbose_error()` to + avoid overflow of `size_t` + # yyjsonr 0.1.17 2024-01-20 * Fixes for CRAN diff --git a/src/R-yyjson-parse.c b/src/R-yyjson-parse.c index 5d8e9df..e92c91f 100644 --- a/src/R-yyjson-parse.c +++ b/src/R-yyjson-parse.c @@ -1807,8 +1807,7 @@ SEXP json_as_robj(yyjson_val *val, parse_options *opt) { #define ERR_CONTEXT 20 void output_verbose_error(const char *str, yyjson_read_err err) { // Slice off a bit of the string within +/- ERR_CONTEXT of the error pos - size_t min_idx = err.pos - ERR_CONTEXT; - min_idx = min_idx < 0 ? 0 : min_idx; + size_t min_idx = err.pos < ERR_CONTEXT ? 0 : err.pos - ERR_CONTEXT; size_t max_idx = err.pos + ERR_CONTEXT; max_idx = max_idx > strlen(str) ? strlen(str) : max_idx;