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 wrong value of type YEAR on big endian environment. #921

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
4 changes: 2 additions & 2 deletions ext/mysql2/result.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ static void rb_mysql_result_alloc_result_buffers(VALUE self, MYSQL_FIELD *fields
wrapper->result_buffers[i].buffer_length = sizeof(signed char);
break;
case MYSQL_TYPE_SHORT: // short int
case MYSQL_TYPE_YEAR: // short int
wrapper->result_buffers[i].buffer = xcalloc(1, sizeof(short int));
wrapper->result_buffers[i].buffer_length = sizeof(short int);
break;
case MYSQL_TYPE_INT24: // int
case MYSQL_TYPE_LONG: // int
case MYSQL_TYPE_YEAR: // int
wrapper->result_buffers[i].buffer = xcalloc(1, sizeof(int));
wrapper->result_buffers[i].buffer_length = sizeof(int);
break;
Expand Down Expand Up @@ -365,6 +365,7 @@ static VALUE rb_mysql_result_fetch_row_stmt(VALUE self, MYSQL_FIELD * fields, co
}
break;
case MYSQL_TYPE_SHORT: // short int
case MYSQL_TYPE_YEAR: // short int
if (result_buffer->is_unsigned) {
val = UINT2NUM(*((unsigned short int*)result_buffer->buffer));
} else {
Expand All @@ -373,7 +374,6 @@ static VALUE rb_mysql_result_fetch_row_stmt(VALUE self, MYSQL_FIELD * fields, co
break;
case MYSQL_TYPE_INT24: // int
case MYSQL_TYPE_LONG: // int
case MYSQL_TYPE_YEAR: // int
if (result_buffer->is_unsigned) {
val = UINT2NUM(*((unsigned int*)result_buffer->buffer));
} else {
Expand Down