File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -165,7 +165,12 @@ public function mapRawData(array $data)
165
165
break ;
166
166
case self ::FOCALLENGTH :
167
167
$ parts = explode ('/ ' , $ value );
168
- $ value = (int ) reset ($ parts ) / (int ) end ($ parts );
168
+ // Avoid division by zero if focal length is invalid
169
+ if (end ($ parts ) == '0 ' ) {
170
+ $ value = 0 ;
171
+ } else {
172
+ $ value = (int ) reset ($ parts ) / (int ) end ($ parts );
173
+ }
169
174
break ;
170
175
case self ::XRESOLUTION :
171
176
case self ::YRESOLUTION :
Original file line number Diff line number Diff line change @@ -138,6 +138,21 @@ public function testMapRawDataCorrectlyFormatsFocalLength()
138
138
$ this ->assertEquals (6 , reset ($ mapped ));
139
139
}
140
140
141
+ /**
142
+ * @group mapper
143
+ * @covers \PHPExif\Mapper\Native::mapRawData
144
+ */
145
+ public function testMapRawDataCorrectlyFormatsFocalLengthDivisionByZero ()
146
+ {
147
+ $ rawData = array (
148
+ \PHPExif \Mapper \Native::FOCALLENGTH => '1/0 ' ,
149
+ );
150
+
151
+ $ mapped = $ this ->mapper ->mapRawData ($ rawData );
152
+
153
+ $ this ->assertEquals (0 , reset ($ mapped ));
154
+ }
155
+
141
156
/**
142
157
* @group mapper
143
158
* @covers \PHPExif\Mapper\Native::mapRawData
You can’t perform that action at this time.
0 commit comments