diff --git a/src/grib_expression_class_accessor.c b/src/grib_expression_class_accessor.c index 07c9159a7..372888cc8 100644 --- a/src/grib_expression_class_accessor.c +++ b/src/grib_expression_class_accessor.c @@ -125,13 +125,16 @@ static string evaluate_string(grib_expression* g, grib_handle* h, char* buf, siz start += *size; if (e->length != 0) { - memcpy(buf, mybuf + start, e->length); + if (start > 0) + memcpy(buf, mybuf + start, e->length); buf[e->length] = 0; } else { - memcpy(buf, mybuf, *size); - if (*size == 1024) - *size = *size - 1; /* ECC-336 */ + if (*size > 0) { + memcpy(buf, mybuf, *size); + if (*size == 1024) + *size = *size - 1; /* ECC-336 */ + } buf[*size] = 0; } return buf; diff --git a/src/grib_expression_class_string_compare.c b/src/grib_expression_class_string_compare.c index cdae91f55..eb3501ad9 100644 --- a/src/grib_expression_class_string_compare.c +++ b/src/grib_expression_class_string_compare.c @@ -107,8 +107,8 @@ static int evaluate_long(grib_expression* g, grib_handle* h, long* lres) size_t l1 = sizeof(b1); char b2[1024]; size_t l2 = sizeof(b2); - const char* v1; - const char* v2; + const char* v1 = NULL; + const char* v2 = NULL; grib_expression_string_compare* e = (grib_expression_string_compare*)g;