Ignore:
Timestamp:
Nov 18, 2016, 5:31:43 PM (7 years ago)
Author:
Bruno Cornec
Message:

Fix call_program_and_get_last_line_of_output which was aborting due to an
excessive loop call

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mondo/src/common/libmondo-fork.c

    r3610 r3615  
    3838 * caller
    3939 */
    40 char *call_program_and_get_last_line_of_output(char *call)
    41 {
     40char *call_program_and_get_last_line_of_output(const char *call) {
    4241    /*@ buffers ***************************************************** */
    4342    char *result = NULL;
    44     char *tmp = NULL;
     43    char *resultbkp = NULL;
     44    char *result2 = NULL;
    4545
    4646    /*@ pointers **************************************************** */
     
    5959            if (strlen(result) > 1) {
    6060                log_msg(7, "result = '%s'", result);
     61                /* in case we have to loop, we keep the
     62                 * previous value */
     63                mr_free(resultbkp);
     64                mr_asprintf(resultbkp, "%s", result);
     65            } else {
     66                /* we had to loop and got nothing useul, so we keep the
     67                 * previous value */
     68                mr_free(result);
     69                result = resultbkp;
    6170            }
    6271        }
     
    6675    }
    6776    mr_free(eng_call);
    68     mr_strip_spaces(result);
    69     log_msg(5, "cpaglloo returns '%s'", result);
    70     return(result);
     77    if (result != NULL) {
     78        result2 = mr_strip_spaces(result);
     79        mr_free(result);
     80        log_msg(5, "cpaglloo returns '%s'", result2);
     81    } else {
     82        mr_asprintf(result2, "");
     83    }
     84    return(result2);
    7185}
    7286
Note: See TracChangeset for help on using the changeset viewer.