Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a segfault issue #407

Merged
merged 1 commit into from
Mar 31, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/search.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ static int is_empty(const char *s) {
}

SEXP find_unbalanced_bracket(SEXP content, SEXP _row, SEXP _col, SEXP _skip_el) {
int ncontent = Rf_length(content);
int row = Rf_asInteger(_row);
int col = Rf_asInteger(_col);
int skip = Rf_asInteger(_skip_el);

int i, j, k;
int i, j;
int k = 0;
int n;
const char* c;
unsigned char cj;
Expand All @@ -29,7 +31,7 @@ SEXP find_unbalanced_bracket(SEXP content, SEXP _row, SEXP _col, SEXP _skip_el)
int nunbalanced = 0;
char brac[2] = " \x00";

for (i = row; i >= 0; i--) {
for (i = row; i >= 0 && i < ncontent; i--) {
c = Rf_translateCharUTF8(STRING_ELT(content, i));
if (skip && i < row && is_empty(c)) {
// skip empty row when search backward
Expand Down