From 8dda834bf9851357fdaae7a6ebd76b157bb91c7a Mon Sep 17 00:00:00 2001
From: Christian Hoene <christian.hoene@symonics.com>
Date: Sun, 24 Jan 2021 18:20:42 +0100
Subject: [PATCH] Fix coverity warning

---
 src/hdf/dataobject.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/hdf/dataobject.c b/src/hdf/dataobject.c
index b606057..9aa3f82 100644
--- a/src/hdf/dataobject.c
+++ b/src/hdf/dataobject.c
@@ -67,11 +67,11 @@ static int readOHDRHeaderMessageDataspace1(struct READER *reader,
     if (i < 4) {
       ds->dimension_size[i] =
           readValue(reader, reader->superblock.size_of_lengths);
-      mylog("   dimension %d %" PRIu64 "\n", i, ds->dimension_size[i]);
-      if (ds->dimension_size[i] > 1000000) {
+      if (ds->dimension_size[i] < 0 || ds->dimension_size[i] > 1000000) {
         mylog("dimension_size is too large\n"); // LCOV_EXCL_LINE
         return MYSOFA_INVALID_FORMAT;           // LCOV_EXCL_LINE
       }
+      mylog("   dimension %d %" PRIu64 "\n", i, ds->dimension_size[i]);
     } else
       readValue(reader, reader->superblock.size_of_lengths);
   }