summaryrefslogtreecommitdiffstats
path: root/generic/tkImgListFormat.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2021-04-05 20:19:28 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2021-04-05 20:19:28 (GMT)
commitff51c7383481f2bd7c3695c420b7b82be2599f41 (patch)
tree0fb51ae2459f14a3683ca6d699fc6dcd963056af /generic/tkImgListFormat.c
parent05b61c74360a756990f65312088926ffaa04be09 (diff)
downloadtk-ff51c7383481f2bd7c3695c420b7b82be2599f41.zip
tk-ff51c7383481f2bd7c3695c420b7b82be2599f41.tar.gz
tk-ff51c7383481f2bd7c3695c420b7b82be2599f41.tar.bz2
Always measure color string in bytes, not (unicode?) chars.
Diffstat (limited to 'generic/tkImgListFormat.c')
-rw-r--r--generic/tkImgListFormat.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/generic/tkImgListFormat.c b/generic/tkImgListFormat.c
index 98a56cf..824d303 100644
--- a/generic/tkImgListFormat.c
+++ b/generic/tkImgListFormat.c
@@ -44,7 +44,7 @@
* longer than this limit
*/
-#define TK_PHOTO_MAX_COLOR_CHARS 99
+#define TK_PHOTO_MAX_COLOR_LENGTH 99
/*
* Symbols for the different formats of a color string.
@@ -413,7 +413,8 @@ StringMatchDef(
if (Tcl_ListObjIndex(interp, rowListPtr[0], 0, &pixelData) != TCL_OK) {
return 0;
}
- if (Tcl_GetCharLength(pixelData) > TK_PHOTO_MAX_COLOR_CHARS) {
+ (void)Tcl_GetString(pixelData);
+ if (pixelData->length > TK_PHOTO_MAX_COLOR_LENGTH) {
return 0;
}
if (ParseColor(interp, pixelData, Tk_Display(Tk_MainWindow(interp)),
@@ -775,30 +776,30 @@ ParseColor(
unsigned char *alphaPtr)
{
const char *specString;
- TkSizeT charCount;
+ TkSizeT length;
/*
* Find out which color format we have
*/
- specString = Tcl_GetStringFromObj(specObj, &charCount);
+ specString = Tcl_GetStringFromObj(specObj, &length);
- if (charCount == 0) {
+ if (length == 0) {
/* Empty string */
*redPtr = *greenPtr = *bluePtr = *alphaPtr = 0;
return TCL_OK;
}
- if (charCount > TK_PHOTO_MAX_COLOR_CHARS) {
+ if (length > TK_PHOTO_MAX_COLOR_LENGTH) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf("invalid color"));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
"INVALID_COLOR", NULL);
return TCL_ERROR;
}
if (specString[0] == '#') {
- return ParseColorAsHex(interp, specString, charCount, display,
+ return ParseColorAsHex(interp, specString, length, display,
colormap, redPtr, greenPtr, bluePtr, alphaPtr);
}
- if (ParseColorAsList(interp, specString, charCount,
+ if (ParseColorAsList(interp, specString, length,
redPtr, greenPtr, bluePtr, alphaPtr) == TCL_OK) {
return TCL_OK;
}
@@ -809,7 +810,7 @@ ParseColor(
*/
Tcl_ResetResult(interp);
- return ParseColorAsStandard(interp, specString, charCount, display,
+ return ParseColorAsStandard(interp, specString, length, display,
colormap, redPtr, greenPtr, bluePtr, alphaPtr);
}
@@ -1005,7 +1006,7 @@ ParseColorAsStandard(
{
XColor parsedColor;
const char *suffixString, *colorString;
- char colorBuffer[TK_PHOTO_MAX_COLOR_CHARS + 1];
+ char colorBuffer[TK_PHOTO_MAX_COLOR_LENGTH + 1];
char *tmpString;
double fracAlpha;
unsigned int suffixAlpha;