[Mesa-dev] [PATCH 1/1] clover: Remove compat::string::c_str
Francisco Jerez
currojerez at riseup.net
Thu Sep 4 23:30:52 PDT 2014
Jan Vesely <jan.vesely at rutgers.edu> writes:
> It's unsafe as compat::string is not null terminated.
> Fixes garbage log on successful build.
>
> Signed-off-by: Jan Vesely <jan.vesely at rutgers.edu>
> ---
>
> It's obviously not needed in program::build, but I'm not sure
> if runtime_error solution is the best one.
>
Meh, I've just pushed the fix for c_str() I submitted to the list weeks
ago:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b4539274b6478249d52e99fa34243daacf48be80
Thanks.
>
> src/gallium/state_trackers/clover/core/program.cpp | 4 ++--
> src/gallium/state_trackers/clover/util/compat.cpp | 2 +-
> src/gallium/state_trackers/clover/util/compat.hpp | 5 -----
> 3 files changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/src/gallium/state_trackers/clover/core/program.cpp b/src/gallium/state_trackers/clover/core/program.cpp
> index 30a1f0e..3e9abec 100644
> --- a/src/gallium/state_trackers/clover/core/program.cpp
> +++ b/src/gallium/state_trackers/clover/core/program.cpp
> @@ -61,9 +61,9 @@ program::build(const ref_vector<device> &devs, const char *opts) {
> dev.ir_target(), build_opts(dev),
> log));
> _binaries.insert({ &dev, module });
> - _logs.insert({ &dev, std::string(log.c_str()) });
> + _logs.insert({ &dev, std::string(log) });
> } catch (const build_error &) {
> - _logs.insert({ &dev, std::string(log.c_str()) });
> + _logs.insert({ &dev, std::string(log) });
> throw;
> }
> }
> diff --git a/src/gallium/state_trackers/clover/util/compat.cpp b/src/gallium/state_trackers/clover/util/compat.cpp
> index 80d5b3e..afba92e 100644
> --- a/src/gallium/state_trackers/clover/util/compat.cpp
> +++ b/src/gallium/state_trackers/clover/util/compat.cpp
> @@ -34,5 +34,5 @@ exception::what() const {
>
> const char *
> runtime_error::what() const {
> - return _what.c_str();
> + return ((std::string)_what).c_str();
> }
> diff --git a/src/gallium/state_trackers/clover/util/compat.hpp b/src/gallium/state_trackers/clover/util/compat.hpp
> index 50e1c7d..b3668c5 100644
> --- a/src/gallium/state_trackers/clover/util/compat.hpp
> +++ b/src/gallium/state_trackers/clover/util/compat.hpp
> @@ -280,11 +280,6 @@ namespace clover {
> }
>
> const char *
> - c_str() const {
> - return begin();
> - }
> -
> - const char *
> find(const string &s) const {
> for (size_t i = 0; i + s.size() < size(); ++i) {
> if (!std::memcmp(begin() + i, s.begin(), s.size()))
> --
> 1.9.3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 212 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140905/cfcaccd2/attachment.sig>
More information about the mesa-dev
mailing list