Check for error in func condition_true

This commit is contained in:
Shahram Najm 2016-02-12 17:14:29 +00:00
parent 1e404d67a5
commit 53e043c382
1 changed files with 7 additions and 5 deletions

View File

@ -227,18 +227,20 @@ static grib_accessor* search_by_rank(grib_handle* h, const char* name,const char
}
static int condition_true(grib_accessor* a,codes_condition* condition) {
int ret=0;
int ret=0, err=0;
size_t size=1;
long lval=0;
double dval=0;
switch (condition->rightType) {
case GRIB_TYPE_LONG:
grib_unpack_long(a,&lval,&size);
ret = lval==condition->rightLong ? 1 : 0;
err = grib_unpack_long(a,&lval,&size);
if (err) ret = 0;
else ret = lval==condition->rightLong ? 1 : 0;
break;
case GRIB_TYPE_DOUBLE:
grib_unpack_double(a,&dval,&size);
ret = dval==condition->rightDouble ? 1 : 0;
err = grib_unpack_double(a,&dval,&size);
if (err) ret = 0;
else ret = dval==condition->rightDouble ? 1 : 0;
break;
default :
ret=0;