Fix for memory leak #75

Merged
asmeron merged 1 commits from YanTheKaller/libublsettings:master into master 3 months ago

@ -248,10 +248,10 @@ char *yon_char_divide_search(char *source, char *dividepos, int delete_divider)
char *yon_char_from_int(int int_to_convert) char *yon_char_from_int(int int_to_convert)
{ {
int i = snprintf( NULL, 0, "%d", int_to_convert ); int i = snprintf( NULL, 0, "%d", int_to_convert)+1;
char *ch = malloc(i * sizeof(char) + 1+ int_to_convert<0?1:0); char *ch = malloc(i * sizeof(char));
memset(ch,0,i * sizeof(char) + 1); memset(ch,0,i * sizeof(char));
sprintf(ch, "%d", int_to_convert); sprintf(ch, "%d", int_to_convert);
return ch; return ch;
} }

Loading…
Cancel
Save