My code work when i run on my lap but when i upload it to hackerrank i got error at atoi : i am doing a problem from hackerrank here is the problem: https://www.hackerrank.com/challenges/time-conversion/problem

__tl;lr__ we take time like 08:00:00PM and convert it to 20:00:00

the str_split function i take from this site: https://stackoverflow.com/questions/9210528/split-string-with-delimiters-in-c

first here is my full code:

    #include <stdio.h>
    #include <string.h>
    #include <stdbool.h>
    #include <stdlib.h>
    #include <assert.h>
   
    char* timeConverse(char* chr)
    {
        int del1 = 8;
        int hour = 0;
        char str[3];
        char *result = malloc(10 * sizeof(str));
        char** tokens;
    
        char s[11];
        for (int i = 0; i < 11; i++)
        {
            s[i] = *(chr + i);
        }
    
        bool time_of_day = 0; // 0 is morning, 1 is afternoon
    
        tokens = str_split(s, ';');
        char *endptr;
        hour = strtol(*(tokens), &endptr, 10); // THE MAIN PROBLEM FOR SEGFAULT I THINK?
        free(tokens);
    
        // check if it is morning or afternoon
        if (s[8] == 'P')
            time_of_day = 1;
    
        // if it is afternoon add 12 to hour
        if (time_of_day)
        {
            hour += 12;
            //
            // remove the hour from the timer
            memmove(&s[0], &s[0 + 1], strlen(s) - 0);
            memmove(&s[0], &s[0 + 1], strlen(s) - 0);
    
            // turn hour from int to string and store that to str
            sprintf(str, "%d", hour);
        }
    
        // remove the last 2 element from the list (PM or AM)
        s[strlen(s) - 1] = 0;
        s[strlen(s) - 1] = 0;
    
        // add hour to the min and second and store to result
        sprintf(result, "%s%s", str, s);
    
        // print out the result
        return result;
        free(result);
    }
    
    int main(void)
    {
        char* time = "07:05:45PM";
        char* result = timeConverse(time);
        printf("%s\n", result);
        return 0;
    }

it work on my pc but when i run my code on hackerrank, i upload the code into the timeConversion function, i got this error:

     GDB trace:
    Reading symbols from solution...done.
    [New LWP 11121]
    Core was generated by `solution'.
    Program terminated with signal SIGSEGV, Segmentation fault.
    #0  __GI_____strtol_l_internal (
        nptr=0x5847d900 <error: Cannot access memory at address 0x5847d900>, 
        endptr=0x7ffd1f2ba350, base=10, group=<optimized out>, 
        loc=0x7f60be451560 <_nl_global_locale>) at ../stdlib/strtol_l.c:292
    #0  __GI_____strtol_l_internal (
        nptr=0x5847d900 <error: Cannot access memory at address 0x5847d900>, 
        endptr=0x7ffd1f2ba350, base=10, group=<optimized out>, 
        loc=0x7f60be451560 <_nl_global_locale>) at ../stdlib/strtol_l.c:292
    #1  0x0000555a56bd0d43 in timeConversion (chr=<optimized out>)
        at solution.c:89
    #2  0x0000555a56bd0a4e in main () at solution.c:126

i assume that the hackerrank compiler different from my compiler computer. 
i compile the code using 
gcc (Debian 8.2.0-12) 8.2.0.
