diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-05-08 11:18:52 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2017-05-08 11:18:52 (GMT) |
commit | 83920326ba5851cad594e6a261205a202b75a338 (patch) | |
tree | 02f945da86cca6f9173441bd599af6aa6fcd892b /generic | |
parent | cfbabe08a1a584f554365f7387e6c7a59799e0c8 (diff) | |
download | tk-83920326ba5851cad594e6a261205a202b75a338.zip tk-83920326ba5851cad594e6a261205a202b75a338.tar.gz tk-83920326ba5851cad594e6a261205a202b75a338.tar.bz2 |
Don't use sizeof(struct) when the structure has a char array as last element: If the size of this array changes, we'll be in trouble.
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tkSelect.c | 4 | ||||
-rw-r--r-- | generic/tkTextDisp.c | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/generic/tkSelect.c b/generic/tkSelect.c index ab9018a..d763411 100644 --- a/generic/tkSelect.c +++ b/generic/tkSelect.c @@ -190,8 +190,8 @@ Tk_CreateSelHandler( * should make a copy for this selPtr. */ - unsigned cmdInfoLen = Tk_Offset(CommandInfo, command) + - ((CommandInfo *)clientData)->cmdLength + 1; + unsigned cmdInfoLen = Tk_Offset(CommandInfo, command) + 1 + + ((CommandInfo *)clientData)->cmdLength; selPtr->clientData = ckalloc(cmdInfoLen); memcpy(selPtr->clientData, clientData, cmdInfoLen); diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 371e910..03d11e1 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -7561,7 +7561,7 @@ TkTextCharLayoutProc( ciPtr = &bciPtr->ci; } else { bciPtr = baseCharChunkPtr->clientData; - ciPtr = ckalloc(sizeof(CharInfo)); + ciPtr = ckalloc(Tk_Offset(CharInfo, chars) + 1); baseString = &bciPtr->baseChars; } |