Skip to content

Commit

Permalink
Fix for garbled strings
Browse files Browse the repository at this point in the history
  • Loading branch information
vimsh authored May 29, 2018
1 parent 4522e6d commit fcb7f3a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sybase_driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ class result_set : public dbi::iresult_set

void allocate(const size_t size)
{
data.resize(size, '\0');
data.resize(size);
std::memset(data.data(), 0, size);
}

operator char*()
Expand Down Expand Up @@ -400,7 +401,7 @@ class result_set : public dbi::iresult_set
default:
throw std::runtime_error(std::string(__FUNCTION__).append(": Invalid column data type (supported: char, varchar, text)"));
}
return std::move(std::string(columndata[col_idx]));
return std::move(std::string((char*)columndata[col_idx], 0, columndata[col_idx].data.size()));
}

virtual int get_date(size_t col_idx)
Expand Down Expand Up @@ -472,7 +473,7 @@ class result_set : public dbi::iresult_set
default:
throw std::runtime_error(std::string(__FUNCTION__).append(": Invalid column data type: ").append(std::to_string(columns[col_idx].datatype)));
}
return std::u16string(reinterpret_cast<char16_t*>((char*)columndata[col_idx]));
return std::move(std::u16string(reinterpret_cast<char16_t*>((char*)columndata[col_idx]), 0, columndata[col_idx].data.size() / sizeof(char16_t)));
}

virtual std::vector<uint8_t> get_binary(size_t col_idx)
Expand Down

0 comments on commit fcb7f3a

Please sign in to comment.