条目数为6或10时出现错误

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

FILE* ip;
FILE* op;

int main(int argv,char* args[]) {
    ip = fopen(args[1],"r");
    op = fopen(args[2],"wr");

    char *line;
    size_t len = 0;
    len = getline(&line,&len,ip);
    int arr_index = 0;
    int *arr = malloc(sizeof(int)*((len-1)/2));

    char *ptr = strtok(line, " ");
    while(ptr != NULL){
        arr[arr_index++] = atoi(ptr);
        ptr = strtok(NULL," "); //line대신 NULL
    }
    for(int i=0 ; arr[i] ; i++){
        printf("%d ",arr[i]);
    }
//Do not use sizeof() (Because this is the part of my code. Later I need to size this way instead of using 'sizeof'.
}

它可以用其他数字正常工作,但是当数字为6或10时只会发生错误。(测试范围为1到30)

输入:“ 1 2 3 4 5 6”->输出:“ 1 2 3 4 5 6 1041”

输入:“ 1 2 3 4 5 6”->输出:lab9:malloc.c:2401:sysmalloc:声明`(old_top == initial_top(av)&& old_size == 0)|| (((无符号长)(old_size)> =最小大小&& prev_inuse(old_top)&&((无符号长)old_end&(页面大小-1))== 0)'失败。

输入:“ 1 2 3 4 5 6 7 8 9 10”->输出:“ 1 2 3 4 5 6 7 8 9 10 1041”

输入:“ 1 2 3 4 5 6 7 8 9 10”->输出:“ 1 2 3 4 5 6 7 8 9 10”