dtstyle: fix bugs preventing SM save from working properly
All of the dtstyle session save routines used sprintf/snprintf whereby
the destination buffer was also a source buffer, like so:
snprintf(bufr, sizeof(style.tmpBigStr), "%s*Fonts.x: %d\n", bufr, x);
^^^^ ^^ ^^^^
That results in undefined behavior, which mainly meant missing or
currupted XRM resources being saved in the session file for dtstyle.
This commit is contained in:
@@ -775,21 +775,22 @@ saveMain(
|
||||
int fd )
|
||||
{
|
||||
Position x,y;
|
||||
char *bufr = style.tmpBigStr; /* size=[1024], make bigger if needed */
|
||||
char bufr[1024]; /* size=[1024], make bigger if needed */
|
||||
|
||||
if (style.mainWindow != NULL) {
|
||||
if (XtIsRealized(style.mainWindow))
|
||||
{
|
||||
sprintf(bufr, "*mainWindow.ismapped: True\n");
|
||||
|
||||
WRITE_STR2FD(fd, bufr);
|
||||
}
|
||||
|
||||
/* Get and write out the geometry info for our Window */
|
||||
x = XtX(XtParent(style.mainWindow));
|
||||
y = XtY(XtParent(style.mainWindow));
|
||||
snprintf(bufr, sizeof(style.tmpBigStr), "%s*mainWindow.x: %d\n", bufr, x);
|
||||
snprintf(bufr, sizeof(style.tmpBigStr), "%s*mainWindow.y: %d\n", bufr, y);
|
||||
|
||||
if(-1 == write (fd, bufr, strlen(bufr))) {
|
||||
perror(strerror(errno));
|
||||
}
|
||||
snprintf(bufr, sizeof(bufr), "*mainWindow.x: %d\n", x);
|
||||
WRITE_STR2FD(fd, bufr);
|
||||
snprintf(bufr, sizeof(bufr), "*mainWindow.y: %d\n", y);
|
||||
WRITE_STR2FD(fd, bufr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user