Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix potential use of uninitialized variable flagged by clang static analyzer |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
01ac8739ab148160b39d604439cdab1f |
User & Date: | das 2008-12-07 16:34:12 |
Context
2008-12-07
| ||
16:34 | Fix potential null dereference flagged by clang static analyzer check-in: 6f14ab51 user: das tags: trunk | |
16:34 | Fix potential use of uninitialized variable flagged by clang static analyzer check-in: 01ac8739 user: das tags: trunk | |
16:32 | Fix leaks flagged by clang static analyzer check-in: 4d3adc5d user: das tags: trunk | |
Changes
Changes to generic/tkCanvPs.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* * tkCanvPs.c -- * * This module provides Postscript output support for canvases, including * the "postscript" widget command plus a few utility functions used for * generating Postscript. * * Copyright (c) 1991-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* * tkCanvPs.c -- * * This module provides Postscript output support for canvases, including * the "postscript" widget command plus a few utility functions used for * generating Postscript. * * Copyright (c) 1991-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: @(#) $Id: tkCanvPs.c,v 1.25 2008/12/07 16:34:12 das Exp $ */ #include "tkInt.h" #include "tkCanvas.h" #include "tkFont.h" /* |
︙ | ︙ | |||
1251 1252 1253 1254 1255 1256 1257 | /* * Figure out which color level to use (possibly lower than the one * specified by the user). For example, if the user specifies color with * monochrome screen, use gray or monochrome mode instead. */ | | | | 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 | /* * Figure out which color level to use (possibly lower than the one * specified by the user). For example, if the user specifies color with * monochrome screen, use gray or monochrome mode instead. */ if (!cdata.color && level >= 2) { level = 1; } if (!cdata.color && cdata.ncolors == 2) { level = 0; } /* * Check that at least one row of the image can be represented with a * string less than 64 KB long (this is a limit in the Postscript * interpreter). */ switch (level) { case 0: bytesPerLine = (width + 7) / 8; maxWidth = 240000; break; case 1: bytesPerLine = width; maxWidth = 60000; break; default: bytesPerLine = 3 * width; maxWidth = 20000; break; } if (bytesPerLine > 60000) { Tcl_ResetResult(interp); sprintf(buffer, "Can't generate Postscript for images more than %d pixels wide", maxWidth); |
︙ | ︙ | |||
1296 1297 1298 1299 1300 1301 1302 | sprintf(buffer, "%d %d 1 matrix {\n<", width, rows); Tcl_AppendResult(interp, buffer, NULL); break; case 1: sprintf(buffer, "%d %d 8 matrix {\n<", width, rows); Tcl_AppendResult(interp, buffer, NULL); break; | | | 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 | sprintf(buffer, "%d %d 1 matrix {\n<", width, rows); Tcl_AppendResult(interp, buffer, NULL); break; case 1: sprintf(buffer, "%d %d 8 matrix {\n<", width, rows); Tcl_AppendResult(interp, buffer, NULL); break; default: sprintf(buffer, "%d %d 8 matrix {\n<", width, rows); Tcl_AppendResult(interp, buffer, NULL); break; } for (yy = band; yy > band - rows; yy--) { switch (level) { case 0: { |
︙ | ︙ | |||
1358 1359 1360 1361 1362 1363 1364 | lineLen += 2; if (lineLen > 60) { lineLen = 0; Tcl_AppendResult(interp, "\n", NULL); } } break; | | | 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 | lineLen += 2; if (lineLen > 60) { lineLen = 0; Tcl_AppendResult(interp, "\n", NULL); } } break; default: /* * Finally, color mode. Here, just output the red, green, and * blue values directly. */ for (xx = x; xx < x+width; xx++) { TkImageGetColor(&cdata, XGetPixel(ximage, xx, yy), |
︙ | ︙ | |||
1384 1385 1386 1387 1388 1389 1390 | } break; } } switch (level) { case 0: case 1: sprintf(buffer, ">\n} image\n"); break; | | | 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 | } break; } } switch (level) { case 0: case 1: sprintf(buffer, ">\n} image\n"); break; default: sprintf(buffer, ">\n} false 3 colorimage\n"); break; } Tcl_AppendResult(interp, buffer, NULL); sprintf(buffer, "0 %d translate\n", rows); Tcl_AppendResult(interp, buffer, NULL); } ckfree((char *) cdata.colors); |
︙ | ︙ | |||
1583 1584 1585 1586 1587 1588 1589 | * string less than 64 KB long (this is a limit in the Postscript * interpreter). */ switch (colorLevel) { case 0: bytesPerLine = (width + 7) / 8; maxWidth = 240000; break; case 1: bytesPerLine = width; maxWidth = 60000; break; | | | 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 | * string less than 64 KB long (this is a limit in the Postscript * interpreter). */ switch (colorLevel) { case 0: bytesPerLine = (width + 7) / 8; maxWidth = 240000; break; case 1: bytesPerLine = width; maxWidth = 60000; break; default: bytesPerLine = 3 * width; maxWidth = 20000; break; } if (bytesPerLine > 60000) { Tcl_ResetResult(interp); sprintf(buffer, "Can't generate Postscript for images more than %d pixels wide", maxWidth); Tcl_AppendResult(interp, buffer, NULL); |
︙ | ︙ |
Changes to generic/tkFileFilter.c.
1 2 3 4 5 6 7 8 9 10 11 | /* * tkFileFilter.c -- * * Process the -filetypes option for the file dialogs on Windows and the * Mac. * * Copyright (c) 1996 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /* * tkFileFilter.c -- * * Process the -filetypes option for the file dialogs on Windows and the * Mac. * * Copyright (c) 1996 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: @(#) $Id: tkFileFilter.c,v 1.12 2008/12/07 16:34:12 das Exp $ */ #include "tkInt.h" #include "tkFileFilter.h" static int AddClause(Tcl_Interp *interp, FileFilter *filterPtr, Tcl_Obj *patternsObj, Tcl_Obj *ostypesObj, |
︙ | ︙ | |||
334 335 336 337 338 339 340 | } else { clausePtr->patternsTail->next = globPtr; clausePtr->patternsTail = globPtr; } globPtr->next = NULL; } } | | | 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | } else { clausePtr->patternsTail->next = globPtr; clausePtr->patternsTail = globPtr; } globPtr->next = NULL; } } if (ostypeList != NULL && ostypeCount > 0) { if (macRoman == NULL) { macRoman = Tcl_GetEncoding(NULL, "macRoman"); } for (i=0; i<ostypeCount; i++) { Tcl_DString osTypeDS; int len; MacFileType *mfPtr = (MacFileType *) ckalloc(sizeof(MacFileType)); |
︙ | ︙ |
Changes to generic/tkFont.c.
1 2 3 4 5 6 7 8 9 10 11 12 | /* * tkFont.c -- * * This file maintains a database of fonts for the Tk toolkit. It also * provides several utility functions for measuring and displaying text. * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1998 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /* * tkFont.c -- * * This file maintains a database of fonts for the Tk toolkit. It also * provides several utility functions for measuring and displaying text. * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1998 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: @(#) $Id: tkFont.c,v 1.51 2008/12/07 16:34:12 das Exp $ */ #include "tkInt.h" #include "tkFont.h" #define ROUND16(x) ((short)((x) + 0.5)) |
︙ | ︙ | |||
2671 2672 2673 2674 2675 2676 2677 | int *widthPtr, int *heightPtr) /* Filled with the width and height of the * bounding box for the character specified by * index, if non-NULL. */ { TextLayout *layoutPtr; LayoutChunk *chunkPtr; | | | 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 | int *widthPtr, int *heightPtr) /* Filled with the width and height of the * bounding box for the character specified by * index, if non-NULL. */ { TextLayout *layoutPtr; LayoutChunk *chunkPtr; int i, x = 0, w; Tk_Font tkfont; TkFont *fontPtr; const char *end; if (index < 0) { return 0; } |
︙ | ︙ |
Changes to generic/tkListbox.c.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* * tkListbox.c -- * * This module implements listbox widgets for the Tk toolkit. A listbox * displays a collection of strings, one per line, and provides scrolling * and selection. * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | /* * tkListbox.c -- * * This module implements listbox widgets for the Tk toolkit. A listbox * displays a collection of strings, one per line, and provides scrolling * and selection. * * Copyright (c) 1990-1994 The Regents of the University of California. * Copyright (c) 1994-1997 Sun Microsystems, Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: @(#) $Id: tkListbox.c,v 1.53 2008/12/07 16:34:12 das Exp $ */ #include "default.h" #include "tkInt.h" #ifdef WIN32 #include "tkWinInt.h" |
︙ | ︙ | |||
1332 1333 1334 1335 1336 1337 1338 | if (GetListboxIndex(interp, listPtr, objv[2], 0, &index) != TCL_OK) { return TCL_ERROR; } ChangeListboxView(listPtr, index); } else { type = Tk_GetScrollInfoObj(interp, objc, objv, &fraction, &count); switch (type) { | < < > > > | 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 | if (GetListboxIndex(interp, listPtr, objv[2], 0, &index) != TCL_OK) { return TCL_ERROR; } ChangeListboxView(listPtr, index); } else { type = Tk_GetScrollInfoObj(interp, objc, objv, &fraction, &count); switch (type) { case TK_SCROLL_MOVETO: index = (int) (listPtr->nElements*fraction + 0.5); break; case TK_SCROLL_PAGES: if (listPtr->fullLines > 2) { index = listPtr->topIndex + count*(listPtr->fullLines-2); } else { index = listPtr->topIndex + count; } break; case TK_SCROLL_UNITS: index = listPtr->topIndex + count; break; case TK_SCROLL_ERROR: default: return TCL_ERROR; } ChangeListboxView(listPtr, index); } return TCL_OK; } /* |
︙ | ︙ |
Changes to macosx/tkMacOSXDialog.c.
1 2 3 4 5 6 7 8 9 10 11 12 | /* * tkMacOSXDialog.c -- * * Contains the Mac implementation of the common dialog boxes. * * Copyright (c) 1996-1997 Sun Microsystems, Inc. * Copyright 2001, Apple Computer, Inc. * Copyright (c) 2006-2007 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | /* * tkMacOSXDialog.c -- * * Contains the Mac implementation of the common dialog boxes. * * Copyright (c) 1996-1997 Sun Microsystems, Inc. * Copyright 2001, Apple Computer, Inc. * Copyright (c) 2006-2007 Daniel A. Steffen <[email protected]> * * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * * RCS: @(#) $Id: tkMacOSXDialog.c,v 1.41 2008/12/07 16:34:12 das Exp $ */ #include "tkMacOSXPrivate.h" #include "tkFileFilter.h" #ifndef StrLength #define StrLength(s) (*((unsigned char *) (s))) |
︙ | ︙ | |||
311 312 313 314 315 316 317 | initialDir = Tcl_GetStringFromObj(objv[i + 1], &choiceLen); /* empty strings should be like no selection given */ if (choiceLen == 0) { initialDir = NULL; } break; case OPEN_INITFILE: | | | 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | initialDir = Tcl_GetStringFromObj(objv[i + 1], &choiceLen); /* empty strings should be like no selection given */ if (choiceLen == 0) { initialDir = NULL; } break; case OPEN_INITFILE: initialFile = Tcl_GetStringFromObj(objv[i + 1], &choiceLen); /* empty strings should be like no selection given */ if (choiceLen == 0) { initialFile = NULL; } break; case OPEN_MESSAGE: choice = Tcl_GetStringFromObj(objv[i + 1], &choiceLen); |
︙ | ︙ | |||
372 373 374 375 376 377 378 | if (typeVariablePtr) { FileFilter *filterPtr = ofd.fl.filters; int i = ofd.curType; while (filterPtr && i-- > 0) { filterPtr = filterPtr->next; } | | > | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | if (typeVariablePtr) { FileFilter *filterPtr = ofd.fl.filters; int i = ofd.curType; while (filterPtr && i-- > 0) { filterPtr = filterPtr->next; } Tcl_SetVar(interp, Tcl_GetString(typeVariablePtr), filterPtr ? filterPtr->name : "", 0); } end: TkFreeFileFilters(&ofd.fl); if (initialDesc.dataHandle) { ChkErr(AEDisposeDesc, &initialDesc); } |
︙ | ︙ |