diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/xkbout.c | 5 | ||||
-rw-r--r-- | src/xkbtext.c | 14 |
3 files changed, 17 insertions, 7 deletions
@@ -1,3 +1,8 @@ +2006-04-09 Daniel Stone <daniel@freedesktop.org> + + * src/xkbtext.c: + Coverity #776, 777: Fix memory leaks. + 2006-04-07 Daniel Stone <daniel@freedesktop.org> * src/maprules.c: diff --git a/src/xkbout.c b/src/xkbout.c index 5a2e4e1..a5593fa 100644 --- a/src/xkbout.c +++ b/src/xkbout.c @@ -263,9 +263,12 @@ WriteXKBIndicatorMap( FILE * file, void * priv) { XkbDescPtr xkb; +char *tmp; xkb= result->xkb; - fprintf(file," indicator \"%s\" {\n",XkbAtomGetString(xkb->dpy,name)); + tmp = XkbGetAtomString(xkb->dpy, name); + fprintf(file," indicator \"%s\" {\n",tmp); + xfree(tmp); if (led->flags&XkbIM_NoExplicit) fprintf(file," !allowExplicit;\n"); if (led->flags&XkbIM_LEDDrivesKB) diff --git a/src/xkbtext.c b/src/xkbtext.c index 28592d2..726dc54 100644 --- a/src/xkbtext.c +++ b/src/xkbtext.c @@ -99,6 +99,7 @@ char *rtrn,*tmp; rtrn= tbGetBuffer(len); strncpy(rtrn,tmp,len); rtrn[len]= '\0'; + xfree(tmp); } else { rtrn= tbGetBuffer(1); @@ -123,7 +124,6 @@ XkbVModIndexText(Display *dpy,XkbDescPtr xkb,unsigned ndx,unsigned format) register int len; register Atom *vmodNames; char *rtrn,*tmp; -char numBuf[20]; if (xkb && xkb->names) vmodNames= xkb->names->vmods; @@ -131,11 +131,13 @@ char numBuf[20]; tmp= NULL; if (ndx>=XkbNumVirtualMods) - tmp= "illegal"; + tmp= strdup("illegal"); else if (vmodNames&&(vmodNames[ndx]!=None)) tmp= XkbAtomGetString(dpy,vmodNames[ndx]); - if (tmp==NULL) - sprintf(tmp=numBuf,"%d",ndx); + if (tmp==NULL) { + tmp= xalloc(20 * sizeof(char)); + snprintf(tmp,20,"%d",ndx); + } len= strlen(tmp)+1; if (format==XkbCFile) @@ -144,10 +146,10 @@ char numBuf[20]; len= BUFFER_SIZE-1; rtrn= tbGetBuffer(len); if (format==XkbCFile) { - strcpy(rtrn,"vmod_"); - strncpy(&rtrn[5],tmp,len-4); + snprintf(rtrn, len, "vmod_%s", tmp); } else strncpy(rtrn,tmp,len); + xfree(tmp); return rtrn; } |