Skip to content

Commit 08f21e8

Browse files
authored
Merge pull request #759 from kubo/segv-by-freed-result
Fix SEGV when `wrapper->result` is used after it is freed.
2 parents bb2de50 + a787899 commit 08f21e8

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

ext/mysql2/result.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,9 @@ static VALUE rb_mysql_result_each(int argc, VALUE * argv, VALUE self) {
920920
wrapper->numberOfRows = wrapper->stmt_wrapper ? mysql_stmt_num_rows(wrapper->stmt_wrapper->stmt) : mysql_num_rows(wrapper->result);
921921
wrapper->rows = rb_ary_new2(wrapper->numberOfRows);
922922
} else if (wrapper->rows && !cacheRows) {
923+
if (wrapper->resultFreed) {
924+
rb_raise(cMysql2Error, "Result set has already been freed");
925+
}
923926
mysql_data_seek(wrapper->result, 0);
924927
wrapper->lastRowProcessed = 0;
925928
wrapper->rows = rb_ary_new2(wrapper->numberOfRows);

0 commit comments

Comments
 (0)