Skip to content

Commit

Permalink
close #512
Browse files Browse the repository at this point in the history
  • Loading branch information
gagolews committed Jun 13, 2024
1 parent 4a83095 commit 7d10746
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .devel/sphinx/alphamarek.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def get_book_template(self, e):
self.format_btitle(e, 'title'),
self.format_volume_and_series(e),
sentence [
field('publisher'),
optional_field('publisher'),
optional_field('address'),
self.format_edition(e)
],
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: stringi
Version: 1.8.4
Date: 2024-05-06
Version: 1.8.4.9001
Date: 2024-06-13
Title: Fast and Portable Character String Processing Facilities
Description: A collection of character string/text/natural language
processing tools for pattern searching (e.g., with 'Java'-like regular
Expand Down
5 changes: 5 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog


## 1.8.4.9xxx (under development)

* [BUGFIX] #512: Fixed PROTECT stack imbalance in `stri_encode_from_marked`.


## 1.8.4 (2024-05-06)

* [BUILD TIME] [BUGFIX] #508: Fixed build errors on Windows
Expand Down
17 changes: 12 additions & 5 deletions src/stri_encoding_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,26 +445,33 @@ SEXP stri_enc_toascii(SEXP str)
* @version 0.1-?? (Marek Gagolewski, 2013-11-12)
*
* @version 0.2-1 (Marek Gagolewski, 2014-03-28)
* use StriUcnv
* use StriUcnv
*
* @version 0.2-1 (Marek Gagolewski, 2014-04-01)
* calc required buf size a priori
* calc required buf size a priori
*
* @version 0.3-1 (Marek Gagolewski, 2014-11-04)
* Issue #112: str_prepare_arg* retvals were not PROTECTed from gc
* #112: str_prepare_arg* retvals were not PROTECTed from gc
*
* @version 1.8.4.9001 (Marek Gagolewski, 2024-06-13)
* #512: Fixed PROTECT stack imbalance in `stri_encode_from_marked`.
*/
SEXP stri_encode_from_marked(SEXP str, SEXP to, SEXP to_raw)
{
PROTECT(str = stri__prepare_arg_string(str, "str"));
const char* selected_to = stri__prepare_arg_enc(to, "to", true); /* this is R_alloc'ed */
bool to_raw_logical = stri__prepare_arg_logical_1_notNA(to_raw, "to_raw");

STRI__ERROR_HANDLER_BEGIN(1)
R_len_t str_n = LENGTH(str);
if (str_n <= 0) {
UNPROTECT(1);
return Rf_allocVector(to_raw_logical?VECSXP:STRSXP, 0);
}

STRI__ERROR_HANDLER_BEGIN(1)
StriContainerUTF16 str_cont(str, str_n);

// get the number of strings to convert; if == 0, then you know what's the result
if (str_n <= 0) return Rf_allocVector(to_raw_logical?VECSXP:STRSXP, 0);

// Open converters
StriUcnv ucnv(selected_to);
Expand Down

0 comments on commit 7d10746

Please sign in to comment.