Ouss4 commented on code in PR #1151:
URL:
https://github.com/apache/incubator-nuttx-apps/pull/1151#discussion_r855730651
##########
system/ping/ping.c:
##########
@@ -242,10 +242,17 @@ static void ping_result(FAR const struct ping_result_s
*result)
result->extra / USEC_PER_MSEC);
if (result->nreplies > 0)
{
- long avg = priv->tsum / result->nreplies;
- long long tempnum = priv->tsum2 / result->nreplies -
+ long tmdev = 0;
+ long avg = 0;
+ long long tempnum = 0;
+
+ if (priv->tsum > 0)
Review Comment:
tsum is used to calculate the other variables, if it's 0 all of the rest
will be 0 including the one passed to `ub32sqrtub16` which will end up crashing
due to a division by zero.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]