mirror of
https://github.com/merbanan/rtl_433.git
synced 2026-04-23 11:07:09 -04:00
Fix SIGFPE crash
the minimal count and also min may stay at zero and then we divide by zero causing a SIGFPE. Closes #48
This commit is contained in:
@@ -929,8 +929,10 @@ static void classify_signal() {
|
||||
}
|
||||
}
|
||||
}
|
||||
min_new = min_new / count_min;
|
||||
max_new = max_new / count_max;
|
||||
if (count_min != 0 && count_max != 0) {
|
||||
min_new = min_new / count_min;
|
||||
max_new = max_new / count_max;
|
||||
}
|
||||
|
||||
delta = (min - min_new)*(min - min_new) + (max - max_new)*(max - max_new);
|
||||
min = min_new;
|
||||
@@ -947,7 +949,7 @@ static void classify_signal() {
|
||||
}
|
||||
}
|
||||
/* 50% decision limit */
|
||||
if (max/min > 1) {
|
||||
if (min != 0 && max/min > 1) {
|
||||
fprintf(stderr, "Pulse coding: Short pulse length %d - Long pulse length %d\n", min, max);
|
||||
signal_type = 2;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user