I need some help with `char*` initialization and `strstr` in C. This is the general issue:

I have a function `func1`, which concatenates strings from a `char** arr` until a semicolon is seen:

```
char * func1(int *i,int len,char **arr,char *path) 
{
    (*i)++;
    char* str = malloc(1);
    memset(str, 0, 1);
    for (; *i < len; (*i)++)
    {
        char* currExp = arr[(*i)];
        size_t currExpLen = strlen(currExp);
        size_t stringLen = strlen(str);

        if (strcmp(currExp, ";") != 0 )
        {
            if (currExp[currExpLen-1] == ';')
            {
                currExp[currExpLen-1] = '\0';
            }
            str = realloc(str, (stringLen + currExpLen) * sizeof(char)+2);
            sprintf(str, "%s %s", str, currExp);
        }
    }
    str = replaceBrackets(path,str);

    return str;
}

```

This function replaces a substring in `str` with the string `path`.

```
char* func2(char *path,char *str)
{
    char *t1 = str,  *t2 = str;
    size_t pathLen = strlen(path);

    while ((t1 = strstr(t2, "char")) != NULL)
    {
        size_t rplcIndx = t1 - str;  
        size_t stringLen = strlen(str);
        str = realloc(str, (stringLen + pathLen+1)*sizeof(char));

        memmove(&str[rplcIndx + pathLen], &str[rplcIndx+2], stringLen-rplcIndx-2);
        memcpy(&str[rplcIndx], path, pathLen);

        t2 = &str[rplcIndx+pathLen];
    }
    return str;
}

```

The issue is that valgrind gives an error basically saying that strstr might be using an uninitialized value. To rectify this, I'd have to do something like `char* str = "hello world";`, but then I can't `realloc`, which is an issue.

I have tested my program with random strings and the issue is the fact that valgrind is treating `str` as uninitialized, but I just don't know how to initialize it without getting rid of the ability to realloc. Any suggestions?

The error is:

```
==14356== Conditional jump or move depends on uninitialised value(s)
==14356==    at 0x4C29313: strstr (in path)
==14356==    by 0x401983: func2 (in path)
==14356==    by 0x401B06: func1 (in path)
==14356==    by 0x4013D7: main (in path)
==14356== 
==14358== Syscall param execve(argv[i]) points to uninitialised byte(s)
 at 0x4ECFCB7: execve (in path)
==14308==    by 0x4E6A76C: do_system (in path)
==14308==    by 0x4013ED: main 

```

Edited: Added in the actual functions, changed names and such.