Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5030d342 authored by Sachin Mohan Gadag's avatar Sachin Mohan Gadag Committed by Gerrit - the friendly Code Review server
Browse files

mm-audio: Remove malloc allocation for ptr pointer

Currently free of ptr pointer is failing because
ptr pointer is not pointing to base address of malloc
function. Reason is, strtoul api stores the address
of the first invalid character of input string parameter
to ptr pointer. Hence removing malloc allocation is not
required as value of ptr pointer will be first invalid
input string address.

Change-Id: I612002b15594b666bf9053c3e49bc62a7efb86ee
parent 338fd3bf
Loading
Loading
Loading
Loading
+0 −8
Original line number Original line Diff line number Diff line
@@ -278,12 +278,6 @@ int get_input_and_validate(char *input, datatype type)
        status = -1;
        status = -1;
        goto exit;
        goto exit;
    }
    }
    ptr = (char *)malloc(strlen(input) + 1);
    if (ptr == NULL) {
        DEBUG_PRINT("Low memory\n");
        status = -1;
        goto exit;
    }
    /* Check for negative input */
    /* Check for negative input */
    if (*input == '-') {
    if (*input == '-') {
        DEBUG_PRINT("Negative Number is not allowed\n");
        DEBUG_PRINT("Negative Number is not allowed\n");
@@ -322,8 +316,6 @@ int get_input_and_validate(char *input, datatype type)
            break;
            break;
    }
    }
exit:
exit:
    if (ptr != NULL)
        free(ptr);
    if (status != 0)
    if (status != 0)
        exit(0);
        exit(0);
    return value;
    return value;
+0 −8
Original line number Original line Diff line number Diff line
@@ -291,12 +291,6 @@ int get_input_and_validate(char *input, datatype type)
        status = -1;
        status = -1;
        goto exit;
        goto exit;
    }
    }
    ptr = (char *)malloc(strlen(input) + 1);
    if (ptr == NULL) {
        DEBUG_PRINT("Low memory\n");
        status = -1;
        goto exit;
    }
    /* Check for negative input */
    /* Check for negative input */
    if (*input == '-') {
    if (*input == '-') {
        DEBUG_PRINT("Negative Number is not allowed\n");
        DEBUG_PRINT("Negative Number is not allowed\n");
@@ -335,8 +329,6 @@ int get_input_and_validate(char *input, datatype type)
            break;
            break;
    }
    }
exit:
exit:
    if (ptr != NULL)
        free(ptr);
    if (status != 0)
    if (status != 0)
        exit(0);
        exit(0);
    return value;
    return value;
+0 −8
Original line number Original line Diff line number Diff line
@@ -290,12 +290,6 @@ int get_input_and_validate(char *input, datatype type)
        status = -1;
        status = -1;
        goto exit;
        goto exit;
    }
    }
    ptr = (char *)malloc(strlen(input) + 1);
    if (ptr == NULL) {
        DEBUG_PRINT("Low memory\n");
        status = -1;
        goto exit;
    }
    /* Check for negative input */
    /* Check for negative input */
    if (*input == '-') {
    if (*input == '-') {
        DEBUG_PRINT("Negative Number is not allowed\n");
        DEBUG_PRINT("Negative Number is not allowed\n");
@@ -334,8 +328,6 @@ int get_input_and_validate(char *input, datatype type)
            break;
            break;
    }
    }
exit:
exit:
    if (ptr != NULL)
        free(ptr);
    if (status != 0)
    if (status != 0)
        exit(0);
        exit(0);
    return value;
    return value;