avutil/timestamp: avoid possible FPE when 0 is passed to av_ts_make_time_string2()
Signed-off-by: Marton Balint <cus@passwd.hu> (cherry picked from commit 0d5e3f5a4034b6c9312b7c621e25aa4303a00b6f)
This commit is contained in:
		
							parent
							
								
									28b1dbb4ee
								
							
						
					
					
						commit
						c75cabef94
					
				| @ -24,7 +24,7 @@ char *av_ts_make_time_string2(char *buf, int64_t ts, AVRational tb) | |||||||
|         snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS"); |         snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS"); | ||||||
|     } else { |     } else { | ||||||
|         double val = av_q2d(tb) * ts; |         double val = av_q2d(tb) * ts; | ||||||
|         double log = floor(log10(fabs(val))); |         double log = (fpclassify(val) == FP_ZERO ? -INFINITY : floor(log10(fabs(val)))); | ||||||
|         int precision = (isfinite(log) && log < 0) ? -log + 5 : 6; |         int precision = (isfinite(log) && log < 0) ? -log + 5 : 6; | ||||||
|         int last = snprintf(buf, AV_TS_MAX_STRING_SIZE, "%.*f", precision, val); |         int last = snprintf(buf, AV_TS_MAX_STRING_SIZE, "%.*f", precision, val); | ||||||
|         last = FFMIN(last, AV_TS_MAX_STRING_SIZE - 1) - 1; |         last = FFMIN(last, AV_TS_MAX_STRING_SIZE - 1) - 1; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user