Skip to content

Commit

Permalink
Explicitly cast Exif GPSTimeStamp from double to int and min/max hh:m…
Browse files Browse the repository at this point in the history
…m:ss values
  • Loading branch information
boardend authored and nyalldawson committed Jul 3, 2024
1 parent 75915eb commit bd17c01
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core/raster/qgsexiftools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,10 @@ QVariant decodeExifData( const QString &key, Exiv2::ExifData::const_iterator &it
const QStringList parts = QString::fromStdString( it->toString() ).split( QRegularExpression( QStringLiteral( "\\s+" ) ) );
if ( parts.size() == 3 )
{
const int hour = readRational( it->value(), 0 );
const int minute = readRational( it->value(), 1 );
const int second = readRational( it->value(), 2 );
const int hour = std::max( 0, std::min( 23, static_cast< int >( readRational( it->value(), 0 ) ) ) );
const int minute = std::max( 0, std::min( 59, static_cast< int >( readRational( it->value(), 1 ) ) ) );
const int second = std::max( 0, std::min( 59, static_cast< int >( readRational( it->value(), 2 ) ) ) );

val = QVariant::fromValue( QTime::fromString( QStringLiteral( "%1:%2:%3" )
.arg( QString::number( hour ).rightJustified( 2, '0' ) )
.arg( QString::number( minute ).rightJustified( 2, '0' ) )
Expand Down

0 comments on commit bd17c01

Please sign in to comment.