diff --git a/src/accessor/grib_accessor_class_ascii.cc b/src/accessor/grib_accessor_class_ascii.cc index e6d9a3436..d3c9bea69 100644 --- a/src/accessor/grib_accessor_class_ascii.cc +++ b/src/accessor/grib_accessor_class_ascii.cc @@ -66,16 +66,16 @@ int grib_accessor_ascii_t::pack_string(const char* val, size_t* len) { grib_handle* hand = grib_handle_of_accessor(this); const size_t alen = length_; - if (len[0] > (alen + 1)) { + if (*len > (alen + 1)) { grib_context_log(context_, GRIB_LOG_ERROR, - "pack_string: Wrong size (%zu) for %s, it contains %ld values", - len[0], name_, length_ + 1); - len[0] = 0; + "%s: Buffer too small for %s. It is %zu bytes long (input string len=%zu)", + class_name_, name_, alen, *len); + *len = alen; return GRIB_BUFFER_TOO_SMALL; } for (size_t i = 0; i < alen; i++) { - if (i < len[0]) + if (i < *len) hand->buffer->data[offset_ + i] = val[i]; else hand->buffer->data[offset_ + i] = 0;