mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
dtpad: resove coverity issues
This commit is contained in:
parent
56b53a30a1
commit
db88cb0d13
5 changed files with 14 additions and 15 deletions
|
@ -225,8 +225,8 @@ SetSaveAsDirAndFile(Editor *pPad)
|
||||||
strcpy(dirbuf, pPad->fileStuff.pathDir);
|
strcpy(dirbuf, pPad->fileStuff.pathDir);
|
||||||
/* -----> make sure dir ends in '/' */
|
/* -----> make sure dir ends in '/' */
|
||||||
if (dirbuf[0] != (char )'\0') {
|
if (dirbuf[0] != (char )'\0') {
|
||||||
if (dirbuf[strlen(dirbuf) - 1] != (char)'/')
|
if (strlen(dirbuf) && dirbuf[strlen(dirbuf) - 1] != (char)'/')
|
||||||
strcat(dirbuf, "/");
|
strcat(dirbuf, "/");
|
||||||
} else {
|
} else {
|
||||||
getcwd(dirbuf, MAX_DIR_PATH_LEN - 16);
|
getcwd(dirbuf, MAX_DIR_PATH_LEN - 16);
|
||||||
strcat(dirbuf, "/");
|
strcat(dirbuf, "/");
|
||||||
|
|
|
@ -314,7 +314,7 @@ AddPound(
|
||||||
strcat(returnBuf, "#");
|
strcat(returnBuf, "#");
|
||||||
} else {
|
} else {
|
||||||
sprintf(returnBuf, "#%s", tempBuf);
|
sprintf(returnBuf, "#%s", tempBuf);
|
||||||
if(returnBuf[strlen(returnBuf) - 1] != (char)'#')
|
if(strlen(returnBuf) && returnBuf[strlen(returnBuf) - 1] != (char)'#')
|
||||||
strcat(returnBuf, "#");
|
strcat(returnBuf, "#");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -804,7 +804,10 @@ _poGetFileContents(char **contents, char *file)
|
||||||
if( (fp = fopen(file, "r")) == NULL )
|
if( (fp = fopen(file, "r")) == NULL )
|
||||||
return DtEDITOR_UNREADABLE_FILE;
|
return DtEDITOR_UNREADABLE_FILE;
|
||||||
|
|
||||||
stat(file, &statbuf);
|
if(stat(file, &statbuf) == -1) {
|
||||||
|
fclose(fp);
|
||||||
|
return DtEDITOR_UNREADABLE_FILE;
|
||||||
|
}
|
||||||
nbytes = statbuf.st_size;
|
nbytes = statbuf.st_size;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -814,8 +817,10 @@ _poGetFileContents(char **contents, char *file)
|
||||||
* copy of the data before actually putting it into the widget.
|
* copy of the data before actually putting it into the widget.
|
||||||
*/
|
*/
|
||||||
buf = (char *) malloc(nbytes + 1);
|
buf = (char *) malloc(nbytes + 1);
|
||||||
if (buf == NULL)
|
if (buf == NULL) {
|
||||||
|
fclose(fp);
|
||||||
return DtEDITOR_INSUFFICIENT_MEMORY;
|
return DtEDITOR_INSUFFICIENT_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
nbytes = fread(buf, sizeof(char), nbytes, fp);
|
nbytes = fread(buf, sizeof(char), nbytes, fp);
|
||||||
buf[nbytes] = '\0';
|
buf[nbytes] = '\0';
|
||||||
|
|
|
@ -430,8 +430,8 @@ _psGetResourceFileName(PrintSetup *pSetup)
|
||||||
saveFile = PS_DEFAULT_RESOURCE_FILE;
|
saveFile = PS_DEFAULT_RESOURCE_FILE;
|
||||||
if (! DtSessionSavePath(topLevelWithWmCommand, &savePath, &saveFile))
|
if (! DtSessionSavePath(topLevelWithWmCommand, &savePath, &saveFile))
|
||||||
{
|
{
|
||||||
sprintf(
|
snprintf(
|
||||||
buffer, "%s/%s/%s",
|
buffer, sizeof(buffer), "%s/%s/%s",
|
||||||
getenv(PS_HOME_ENV_VARIABLE),
|
getenv(PS_HOME_ENV_VARIABLE),
|
||||||
DtPERSONAL_TMP_DIRECTORY,
|
DtPERSONAL_TMP_DIRECTORY,
|
||||||
PS_DEFAULT_RESOURCE_FILE);
|
PS_DEFAULT_RESOURCE_FILE);
|
||||||
|
@ -853,7 +853,7 @@ _psAttachPrintSetupDialog(PrintSetup *pSetup, Editor *pPad)
|
||||||
filename = pSetup->docName;
|
filename = pSetup->docName;
|
||||||
else
|
else
|
||||||
filename++;
|
filename++;
|
||||||
sprintf(path, "%s/%s.ps", dirname, filename);
|
snprintf(path, sizeof(path), "%s/%s.ps", dirname, filename);
|
||||||
XtVaSetValues(pSetup->dtprintSetup, DtNfileName, path, NULL);
|
XtVaSetValues(pSetup->dtprintSetup, DtNfileName, path, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -248,7 +248,6 @@ TTmedia_ptype_declareCB(
|
||||||
DtEditorErrorCode errorCode;
|
DtEditorErrorCode errorCode;
|
||||||
Boolean foundPad = False;
|
Boolean foundPad = False;
|
||||||
char *context = (char *)NULL;
|
char *context = (char *)NULL;
|
||||||
char *oldFileName = (char *)NULL;
|
|
||||||
Boolean isCurrentlyVisible = False;
|
Boolean isCurrentlyVisible = False;
|
||||||
int mark = tt_mark();
|
int mark = tt_mark();
|
||||||
char *localPath = tt_message_file(m);
|
char *localPath = tt_message_file(m);
|
||||||
|
@ -428,14 +427,9 @@ TTmedia_ptype_declareCB(
|
||||||
/* -----> Create GUI components of Editor instance, set resouces,
|
/* -----> Create GUI components of Editor instance, set resouces,
|
||||||
* map window and load file (if specified). */
|
* map window and load file (if specified). */
|
||||||
if (!foundPad) {
|
if (!foundPad) {
|
||||||
if (oldFileName != (char *)NULL)
|
|
||||||
XtFree(oldFileName);
|
|
||||||
|
|
||||||
RealizeNewPad(pPad); /* pPad->mainWindow is created here */
|
RealizeNewPad(pPad); /* pPad->mainWindow is created here */
|
||||||
} else {
|
} else {
|
||||||
if (oldFileName != (char *)NULL)
|
ManageOldPad(pPad, isCurrentlyVisible);
|
||||||
XtFree(oldFileName);
|
|
||||||
ManageOldPad(pPad, isCurrentlyVisible);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----> Accept the message.
|
/* -----> Accept the message.
|
||||||
|
|
Loading…
Reference in a new issue