After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 748389 - validate-utils: Passing value -1.0 to sqrt() leads to undefined result
validate-utils: Passing value -1.0 to sqrt() leads to undefined result
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-devtools
unspecified
Other Linux
: Normal normal
: 1.5.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-04-24 00:14 UTC by Vineeth
Modified: 2015-06-24 14:44 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
sqrt(-1) is not valid, hence just returning -1 (1.04 KB, patch)
2015-04-24 00:16 UTC, Vineeth
committed Details | Review

Description Vineeth 2015-04-24 00:14:23 UTC
using sqrt of -1 is not valid and leads to undefined results.
 when comparing the return value of the fucntion in validate-scenario,
 it is being checked with ret == -1, so it makes sense to just return -1 in error case.
Comment 1 Vineeth 2015-04-24 00:16:00 UTC
Created attachment 302269 [details] [review]
sqrt(-1) is not valid, hence just returning -1
Comment 2 Vineeth 2015-05-20 10:29:27 UTC
Can someone review this :)
Comment 3 Vineeth 2015-05-29 04:36:51 UTC
ping :)
Comment 4 Luis de Bethencourt 2015-05-29 13:59:00 UTC
Makes me wonder why sqrt () was used at all.

Let me read more of the context code and the history of it.
Comment 5 Luis de Bethencourt 2015-05-29 14:27:23 UTC
What I expected.

#include <math.h>
#include <stdio.h>

int main () {
  printf ("%f\n", sqrt (-1.0));
  return 0;
}

Returns "-nan"

Good find! :)

One thing though.

  else {
      return -1.0;
  }
  return -1.0;

Why the need for an else there?

Change this to be the following and I will merge:

  if (!setjmp (parser->err_jmp_buf)) {
    result = _read_expr (parser);
    if (parser->pos < parser->len - 1) {
      _error (parser,
          "Failed to reach end of input expression, likely malformed input");
    } else
      return result;
  }

  return -1.0;
Comment 6 Luis de Bethencourt 2015-05-29 14:42:35 UTC
Review of attachment 302269 [details] [review]:

Nevermind, I know you have limited time. So added my suggestion and pushed your patch.

commit 1e3084aa95463547cada647ec4a7d0725b4c43b0

Thanks! Good one.
Comment 7 Vineeth 2015-05-29 22:16:08 UTC
Thanks Luis :)