IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40487


Ignore:
Timestamp:
Jun 27, 2018, 3:58:36 PM (8 years ago)
Author:
eugene
Message:

fix segfault in test for trinary operator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/lib.shell/evaluate_stack.c

    r40315 r40487  
    208208          push_error (line);
    209209
    210           // we need to verify that .name exists for both
    211           if ((stack[i-1].name && strchr(stack[i-1].name, ':')) || (stack[i-2].name && strchr(stack[i-2].name, ':'))) {
     210          int isTrinary = TRUE;
     211          isTrinary = isTrinary && (i >= 2);
     212          // isTrinary = isTrinary && (stack[i - 1] != NULL);
     213          // isTrinary = isTrinary && (stack[i - 2] != NULL);
     214          isTrinary = isTrinary && (stack[i - 1].name != NULL);
     215          isTrinary = isTrinary && (stack[i - 2].name != NULL);
     216          isTrinary = isTrinary && (strchr(stack[i-1].name, ':') || strchr(stack[i-2].name, ':'));
     217          if (isTrinary) {
    212218            snprintf (line, 512, "syntax error: invalid operand for binary operation: %s or %s\n(Note that the : in a trinary operation must be protected by spaces)\n", stack[i-1].name, stack[i-2].name);
    213219            push_error (line);
    214220          }
     221
    215222          clear_stack (&tmp_stack);
    216223          return (FALSE);
Note: See TracChangeset for help on using the changeset viewer.