I'm using g++.

Code:

```
        std::string str = "{\"action\":3,\"data\":{\"account\":\"somehashgoeshear\",\"someint\":0,\"id\":1,\"moreint\":0,\"name\":\"demo\"}}";
        char *cstr = strdup(str.c_str());
        lwsl_notice("\n%s", cstr);
        return lws_write(wsi, (unsigned char*)cstr, strlen(cstr), LWS_WRITE_TEXT);

```

This also doesn't work:

```
        std::string str = "{\"action\":3,\"data\":{\"account\":\"somehashgoeshear\",\"someint\":0,\"id\":1,\"moreint\":0,\"name\":\"demo\"}}";
        return lws_write(wsi, (unsigned char*)str.c_str(), strlen(str.c_str()), LWS_WRITE_TEXT);

```

But this works fine (runs many times without some error):

```
        char cstr[96] = "{\"action\":3,\"data\":{\"account\":\"somehashgoeshear\",\"someint\":0,\"id\":1,\"moreint\":0,\"name\":\"demo\"}}";
        return lws_write(wsi, (unsigned char*)cstr, strlen(cstr), LWS_WRITE_TEXT);

```

Tried also to create string with `malloc` but this doesn't work as well:

```
        std::string str = "{\"action\":3,\"data\":{\"account\":\"somehashgoeshear\",\"someint\":0,\"id\":1,\"moreint\":0,\"name\":\"demo\"}}";
        char *cstr = (char *)malloc((str.length() + 1) * sizeof(char));
        strcpy(cstr, str.c_str());
        lwsl_notice("\n%s", cstr);
        return lws_write(wsi, (unsigned char*)cstr, strlen(cstr), LWS_WRITE_TEXT);

```

**I can run this code couple times but eventually I'm getting this error**:
`free(): invalid next size (fast)`
(fails after data was sent)

I tried also couple experiments with `LWS_PRE` but when I add this to the string it adds couple symbols at the start of message like: `a":`

When I try `free(cstr)` after sending the data it fails immediately with `double free or corruption (out)` error.

lws version: 1.7.1
os: ubuntu x64