diff --git a/libmariadb/ma_dtoa.c b/libmariadb/ma_dtoa.c index f29f1bcce..2c943a221 100644 --- a/libmariadb/ma_dtoa.c +++ b/libmariadb/ma_dtoa.c @@ -1684,8 +1684,9 @@ static char *dtoa(double dd, int mode, int ndigits, int *decpt, int *sign, Bfree(b, &alloc); b= b1; } - if ((j= b5 - m5)) - b= pow5mult(b, j, &alloc); + // redundant comparison, as m5 == b5 + //if ((j= b5 - m5)) + // b= pow5mult(b, j, &alloc); } else b= pow5mult(b, b5, &alloc); diff --git a/libmariadb/ma_hashtbl.c b/libmariadb/ma_hashtbl.c index 4805dee0b..77b22e90b 100644 --- a/libmariadb/ma_hashtbl.c +++ b/libmariadb/ma_hashtbl.c @@ -377,7 +377,7 @@ my_bool ma_hashtbl_insert(MA_HASHTBL *info,const uchar *record) gpos->data=ptr_to_rec; gpos->next=NO_RECORD; } - if ((flag & (HIGHFIND | HIGHUSED)) == HIGHFIND) + if (gpos2 && (flag & (HIGHFIND | HIGHUSED)) == HIGHFIND) { gpos2->data=ptr_to_rec2; gpos2->next=NO_RECORD; diff --git a/libmariadb/ma_stmt_codec.c b/libmariadb/ma_stmt_codec.c index 3dde3c40b..b282885ff 100644 --- a/libmariadb/ma_stmt_codec.c +++ b/libmariadb/ma_stmt_codec.c @@ -1135,7 +1135,7 @@ void ps_fetch_datetime(MYSQL_BIND *r_param, const MYSQL_FIELD * field, } default: { - char dtbuffer[60]; + char dtbuffer[87]; MYSQL_TIME tm; size_t length; convert_to_datetime(&tm, row, len, field->type); @@ -1148,7 +1148,7 @@ void ps_fetch_datetime(MYSQL_BIND *r_param, const MYSQL_FIELD * field, length= sprintf(dtbuffer, "%s%02u:%02u:%02u", (tm.neg ? "-" : ""), tm.hour, tm.minute, tm.second); if (field->decimals && field->decimals <= 6) { - char ms[8]; + char ms[22]; sprintf(ms, ".%06lu", tm.second_part); if (field->decimals < 6) ms[field->decimals + 1]= 0; @@ -1161,7 +1161,7 @@ void ps_fetch_datetime(MYSQL_BIND *r_param, const MYSQL_FIELD * field, length= sprintf(dtbuffer, "%04u-%02u-%02u %02u:%02u:%02u", tm.year, tm.month, tm.day, tm.hour, tm.minute, tm.second); if (field->decimals && field->decimals <= 6) { - char ms[8]; + char ms[22]; sprintf(ms, ".%06lu", tm.second_part); if (field->decimals < 6) ms[field->decimals + 1]= 0; diff --git a/libmariadb/mariadb_dyncol.c b/libmariadb/mariadb_dyncol.c index 42de69eeb..c3e99eed4 100644 --- a/libmariadb/mariadb_dyncol.c +++ b/libmariadb/mariadb_dyncol.c @@ -3830,7 +3830,8 @@ mariadb_dyncol_val_str(DYNAMIC_STRING *str, DYNAMIC_COLUMN_VALUE *val, return ER_DYNCOL_RESOURCE; if (quote) str->str[str->length++]= quote; - ma_dynstr_append_mem(str, buff, len); + if (ma_dynstr_append_mem(str, buff, len)) + return ER_DYNCOL_RESOURCE; if (quote) str->str[str->length++]= quote; break; diff --git a/libmariadb/mariadb_lib.c b/libmariadb/mariadb_lib.c index f9d1d308f..c17a2e318 100644 --- a/libmariadb/mariadb_lib.c +++ b/libmariadb/mariadb_lib.c @@ -304,6 +304,9 @@ ulong net_field_length(uchar **packet) { reg1 uchar *pos= *packet; + if (!pos) + return NULL_LENGTH; + if (*pos < 251) { (*packet)++; @@ -1043,7 +1046,7 @@ unpack_fields(const MYSQL *mysql, for (i=0; i < field_count; i++) { uint length= (uint)(row->data[i+1] - row->data[i] - 1); - if (!row->data[i] && row->data[i][length]) + if (!row->data[i] || row->data[i][length]) goto error; *(char **)(((char *)field) + rset_field_offsets[i*2])= @@ -1246,8 +1249,12 @@ int mthd_my_read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, ulong *lengths) *prev_pos=0; /* Terminate prev field */ prev_pos=pos; } - row[field]=(char*) prev_pos+1; /* End of last field */ - *prev_pos=0; /* Terminate last field */ + + if (prev_pos) + { + row[field]=(char*) prev_pos+1; /* End of last field */ + *prev_pos=0; /* Terminate last field */ + } return 0; } diff --git a/libmariadb/mariadb_rpl.c b/libmariadb/mariadb_rpl.c index 3a0a4e12b..7f98cc5f9 100644 --- a/libmariadb/mariadb_rpl.c +++ b/libmariadb/mariadb_rpl.c @@ -589,7 +589,8 @@ int mariadb_rpl_optionsv(MARIADB_RPL *rpl, else if (arg1) { rpl->filename= strdup((const char *)arg1); - rpl->filename_length= (uint32_t)strlen(rpl->filename); + if (rpl->filename) + rpl->filename_length= (uint32_t)strlen(rpl->filename); } break; } diff --git a/libmariadb/mariadb_stmt.c b/libmariadb/mariadb_stmt.c index 4e77b5ce2..84208ab94 100644 --- a/libmariadb/mariadb_stmt.c +++ b/libmariadb/mariadb_stmt.c @@ -438,7 +438,8 @@ int mthd_stmt_fetch_to_bind(MYSQL_STMT *stmt, unsigned char *row) if (!stmt->bind[i].is_null) stmt->bind[i].is_null= &stmt->bind[i].is_null_value; *stmt->bind[i].is_null= 0; - mysql_ps_fetch_functions[stmt->fields[i].type].func(&stmt->bind[i], &stmt->fields[i], &row); + if (mysql_ps_fetch_functions[stmt->fields[i].type].func != NULL) + mysql_ps_fetch_functions[stmt->fields[i].type].func(&stmt->bind[i], &stmt->fields[i], &row); if (stmt->mysql->options.report_data_truncation) truncations+= *stmt->bind[i].error; } @@ -1560,7 +1561,8 @@ int STDCALL mysql_stmt_fetch_column(MYSQL_STMT *stmt, MYSQL_BIND *bind, unsigned *bind[0].error= 0; bind[0].offset= offset; save_ptr= stmt->bind[column].u.row_ptr; - mysql_ps_fetch_functions[stmt->fields[column].type].func(&bind[0], &stmt->fields[column], &stmt->bind[column].u.row_ptr); + if (mysql_ps_fetch_functions[stmt->fields[column].type].func != NULL) + mysql_ps_fetch_functions[stmt->fields[column].type].func(&bind[0], &stmt->fields[column], &stmt->bind[column].u.row_ptr); stmt->bind[column].u.row_ptr= save_ptr; } return(0);