Commit 79e7dc7e authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

*fixed valgrind memory leak errors.

*TODO: why is alsa's snd_ctl_card_info_free(info) causing double free error (valgrind's "Adress  is is 40 bytes inside a block of size 376 free'd)? No clue. But with that call disabled, everything works as it should and valgrind reports no further errors.
parent 03ef5d01
......@@ -2357,10 +2357,11 @@ void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize, int pos)
canvas_updatewindowlist();
}
else { // T_MESSAGE, T_TEXT, T_ATOM
if (x->te_type == T_TEXT)
if (buf && x->te_type == T_TEXT)
{
char * c;
for(c = buf; *c != '\0'; c++)
char *c;
int n;
for(c = buf, n = 0; n < bufsize; n++, c++)
{
if(*c == '\n')
{
......@@ -2372,7 +2373,7 @@ void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize, int pos)
t_binbuf *b = binbuf_new();
binbuf_text(b, buf, bufsize);
binbuf_gettext(b, &c2, &i2);
if (strcmp(c1, c2))
if (!c1 || strcmp(c1, c2))
{
canvas_undo_add(glist_getcanvas(glist), 10, "typing",
(void *)canvas_undo_set_recreate(glist_getcanvas(glist),
......
......@@ -55,7 +55,7 @@ void *resizebytes(void *old, size_t oldsize, size_t newsize)
void *ret;
if (newsize < 1) newsize = 1;
if (oldsize < 1) oldsize = 1;
ret = (void *)realloc((char *)old, newsize);
ret = (void *)realloc((char *)old, newsize * sizeof(char *));
if (newsize > oldsize && ret)
memset(((char *)ret) + oldsize, 0, newsize - oldsize);
#ifdef LOUD
......
......@@ -847,14 +847,14 @@ void alsa_getdevs(char *indevlist, int *nindevs,
/* apparently, "cardno" is just a counter; but check that here */
if (ndev != cardno)
fprintf(stderr, "oops: ALSA cards not reported in order?\n");
sprintf(devname, "hw:%d", cardno );
/* fprintf(stderr, "\ntry %s...\n", devname); */
sprintf(devname, "hw:%d", cardno);
// fprintf(stderr, "\ntry %s...\n", devname);
if (snd_ctl_open(&ctl, devname, 0) >= 0)
{
snd_ctl_card_info_malloc(&info);
snd_ctl_card_info(ctl, info);
desc = snd_ctl_card_info_get_name(info);
snd_ctl_card_info_free(info);
//snd_ctl_card_info_free(info);
}
else
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment