Skip to content

Commit

Permalink
GTIFSetFromProj4(): avoid unlikely floating point division by zero (C…
Browse files Browse the repository at this point in the history
…ID 1589229)
  • Loading branch information
rouault committed Jan 12, 2025
1 parent e00dcd6 commit 5d5a36d
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions libgeotiff/geotiff_proj4.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/******************************************************************************
* $Id$
*
* Project: libgeotiff
* Purpose: Code to convert a normalized GeoTIFF definition into a PROJ.4
Expand All @@ -9,23 +8,7 @@
******************************************************************************
* Copyright (c) 1999, Frank Warmerdam
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* SPDX-License-Identifier: MIT
******************************************************************************
*/

Expand Down Expand Up @@ -238,7 +221,7 @@ int GTIFSetFromProj4( GTIF *gtif, const char *proj4 )
dfSemiMajor = OSR_GDV(papszNV,"a",0.0);
dfSemiMinor = OSR_GDV(papszNV,"b",0.0);
dfInvFlattening = OSR_GDV(papszNV,"rf",0.0);
if( dfSemiMinor != 0.0 && dfInvFlattening == 0.0 )
if( dfSemiMajor != 0.0 && dfSemiMinor != 0.0 && dfInvFlattening == 0.0 )
dfInvFlattening = -1.0 / (dfSemiMinor/dfSemiMajor - 1.0);
}

Expand Down

0 comments on commit 5d5a36d

Please sign in to comment.