From 7c13e374a052cc34d6434c758f857419426e7b0f Mon Sep 17 00:00:00 2001 From: shahramn Date: Thu, 31 Oct 2024 16:41:46 +0000 Subject: [PATCH] Error messages --- src/accessor/grib_accessor_class_ascii.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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;