[geos-commits] [SCM] GEOS branch main updated. cc9a3cc95d160c58a68ded58fb6b83935ca856fe

git at osgeo.org git at osgeo.org
Fri Oct 2 01:43:22 PDT 2026


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".

The branch, main has been updated
       via  cc9a3cc95d160c58a68ded58fb6b83935ca856fe (commit)
      from  6f4340223234824350773dca530424e55a734e22 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit cc9a3cc95d160c58a68ded58fb6b83935ca856fe
Author: Mohd Quamar Tyagi <104281681+Tyagiquamar at users.noreply.github.com>
Date:   Fri Oct 2 14:12:58 2026 +0530

    geosop: report error and exit non-zero when input file cannot be opened (#1548)
    
    * geosop: report error and exit non-zero when input file cannot be opened
    
    When an input file path does not exist or cannot be opened, std::ifstream
    previously failed silently and returned an empty list of geometries, causing
    geosop to succeed with exit code 0.
    
    Check whether std::ifstream is open in readWKTFile and readWKBFile, throw an exception, caught at CLI boundary
    
    Fixes #1538

diff --git a/util/geosop/GeosOp.cpp b/util/geosop/GeosOp.cpp
index 398085519..844505039 100644
--- a/util/geosop/GeosOp.cpp
+++ b/util/geosop/GeosOp.cpp
@@ -25,6 +25,7 @@
 #include <geos/io/WKBReader.h>
 #include <geos/io/WKBStreamReader.h>
 #include <geos/io/WKBWriter.h>
+#include <geos/util/GEOSException.h>
 
 #if !defined(MISSING_FENV)
 #define HAVE_FENV
@@ -181,8 +182,15 @@ int main(int argc, char** argv) {
         }
     }
 
-    GeosOp geosop(cmdArgs);
-    geosop.run(opArgs);
+    try {
+        GeosOp geosop(cmdArgs);
+        geosop.run(opArgs);
+    }
+    catch (const std::exception& ex) {
+        std::cerr << ex.what() << std::endl;
+        return 1;
+    }
+    return 0;
 }
 
 GeosOp::GeosOp(GeosOpArgs& arg)
@@ -271,6 +279,9 @@ readWKTFile(std::string src, int limit, int offset) {
         return readWKTFile( std::cin, limit, offset );
     }
     std::ifstream f( src );
+    if (!f.is_open()) {
+        throw util::GEOSException("Cannot open file: " + src);
+    }
     auto geoms = readWKTFile( f, limit, offset );
     f.close();
     return geoms;
@@ -299,6 +310,9 @@ readWKBFile(std::string src, int limit, int offset) {
         return readWKBFile( std::cin, limit, offset );
     }
     std::ifstream f( src );
+    if (!f.is_open()) {
+        throw util::GEOSException("Cannot open file: " + src);
+    }
     auto geoms = readWKBFile( f, limit, offset );
     f.close();
     return geoms;

-----------------------------------------------------------------------

Summary of changes:
 util/geosop/GeosOp.cpp | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)


hooks/post-receive
-- 
GEOS


More information about the geos-commits mailing list