petehug / wjelement-cpp

WJElement-cpp - Lightweight C++ wrapper for WJElement with JSON Schema support
GNU Lesser General Public License v3.0
9 stars 3 forks source link

Memory leak with JPN #5

Open sinukus opened 8 years ago

sinukus commented 8 years ago

Hi, In: size_t wjWUTF8CharSize(char *str, size_t length) { size_t r = -1; There is a bug using size_t, in that you check later for -1. l = wjWUTF8CharSize(e, length - (e - value)); .... else if (l < 0)

We found that using int instead fixes the problem.

std::string wjUTF8Encode(char *value)
{
    size_t  length = strlen(value);
    char        *next;
    char        *v;
    char        *e;
    int l; //<- change to int

And same thing here:

int wjWUTF8CharSize(char *str, size_t length) { int r = -1;