From aa4bb4b19ca8c00ac76bd24a00b7d5c895b6f796 Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Tue, 20 Aug 2019 10:37:12 -0400 Subject: [PATCH] Since allowing brackets to be part of cell names in a previous commit, found that DBTreeFindUse fails to find such uses because it strips the array delimiters off the name. Fixed the routine although the routine really should be checking if the use is a 1- or 2- dimensional array and stripping off only the components expected. The current code will probably fail for cell uses that have brackets in the name AND are arrayed. Fortunately this search routine does not appear to be used frequently or in any critical database functions like netlisting. --- database/DBlabel2.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/database/DBlabel2.c b/database/DBlabel2.c index 91c1908d..c060ac14 100644 --- a/database/DBlabel2.c +++ b/database/DBlabel2.c @@ -296,18 +296,25 @@ DBTreeFindUse(name, use, scx) if ((def->cd_flags & CDAVAILABLE) == 0) (void) DBCellRead(def, (char *) NULL, TRUE, NULL); - /* - * Pull off the next component of path up to but not including - * any array subscripts. - */ - for (cp = name; *cp && *cp != '[' && *cp != '/'; cp++) - /* Nothing */; - csave = *cp; - *cp = '\0'; he = HashLookOnly(&def->cd_idHash, name); - *cp = csave; if (he == NULL || HashGetValue(he) == NULL) - return; + { + /* + * Pull off the next component of path up to but not including + * any array subscripts. + * NOTE: This should check the array bounds and only remove + * array components that are expected, not array components + * embedded in the name. + */ + for (cp = name; *cp && *cp != '[' && *cp != '/'; cp++) + /* Nothing */; + csave = *cp; + *cp = '\0'; + he = HashLookOnly(&def->cd_idHash, name); + *cp = csave; + if (he == NULL || HashGetValue(he) == NULL) + return; + } use = (CellUse *) HashGetValue(he); def = use->cu_def;