From dfe85a58a2d402b797eb1433c6ac8a83d280a5c2 Mon Sep 17 00:00:00 2001 From: hobbs Date: Wed, 5 Apr 2006 19:48:07 +0000 Subject: * generic/tkTextDisp.c (TkTextPixelIndex): Don't segfault on full -elide text. [Bug 1442102] --- generic/tkTextDisp.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 4866cfa..22a5a2e 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkTextDisp.c,v 1.14.2.1 2005/11/27 02:44:26 das Exp $ + * RCS: @(#) $Id: tkTextDisp.c,v 1.14.2.2 2006/04/05 19:48:07 hobbs Exp $ */ #include "tkPort.h" @@ -4176,6 +4176,15 @@ TkTextPixelIndex(textPtr, x, y, indexPtr) } if (dlPtr->chunkPtr == NULL) dlPtr = validdlPtr; + *indexPtr = dlPtr->index; + + /* + * If it is still empty, we have nothing to access. [Bug 1442102] + */ + + if (dlPtr->chunkPtr == NULL) { + return; + } /* * Scan through the line's chunks to find the one that contains @@ -4184,7 +4193,6 @@ TkTextPixelIndex(textPtr, x, y, indexPtr) * coordinate system of the line (to take account of x-scrolling). */ - *indexPtr = dlPtr->index; x = x - dInfoPtr->x + dInfoPtr->curPixelOffset; for (chunkPtr = dlPtr->chunkPtr; x >= (chunkPtr->x + chunkPtr->width); indexPtr->byteIndex += chunkPtr->numBytes, -- cgit v0.12