[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#450549: Segmentation fault in kxsldbg



Hi Sune,

Today I have have managed to reproduce the fault mentioned using details 
provided  and offer the attached patch to kxsldbg to try out.

Has that patch fixed the problem? 

Thanks for your patience in handling of this bug.


--
Keith
diff -x '*.*o*' -x '*.moc' -x Makefile -ur ../old/kdewebdev-3.5.8/kxsldbg/kxsldbgpart/libqtnotfier/xsldbgevent.cpp kxsldbg/kxsldbgpart/libqtnotfier/xsldbgevent.cpp
--- kxsldbg/kxsldbgpart/libqtnotfier/xsldbgevent.cpp	2005-09-10 18:23:15.000000000 +1000
+++ kxsldbg/kxsldbgpart/libqtnotfier/xsldbgevent.cpp	2008-02-17 17:03:50.000000000 +1000
@@ -522,7 +522,7 @@
 
 
 
-	if (item->comp && item->comp->inst && item->comp->inst->doc){
+	if (item->computed && item->comp && item->comp->inst && item->comp->inst->doc){
 	  fileName = XsldbgDebuggerBase::fromUTF8FileName(item->comp->inst->doc->URL);
 	  lineNumber= xmlGetLineNo(item->comp->inst);
 	}
@@ -566,7 +566,7 @@
 	  name = (XsldbgDebuggerBase::fromUTF8FileName(item->nameURI)).append(":");
 	name.append(XsldbgDebuggerBase::fromUTF8(item->name));
 
-	if (item->comp && item->comp->inst){
+	if (item->computed && item->comp && item->comp->inst){
 	  varXmlNode = item->comp->inst;
 
 	  /* try to find out what template this variable belongs to */
diff -x '*.*o*' -x '*.moc' -x Makefile -ur ../old/kdewebdev-3.5.8/kxsldbg/kxsldbgpart/libxsldbg/nodeview_cmds.cpp kxsldbg/kxsldbgpart/libxsldbg/nodeview_cmds.cpp
--- kxsldbg/kxsldbgpart/libxsldbg/nodeview_cmds.cpp	2005-09-10 18:23:15.000000000 +1000
+++ kxsldbg/kxsldbgpart/libxsldbg/nodeview_cmds.cpp	2008-02-17 18:01:30.000000000 +1000
@@ -527,47 +527,51 @@
             }
         } else {
             /* list local variables */
-            if (styleCtxt->varsBase) {
-                xsltStackElemPtr item =
-                    styleCtxt->varsTab[styleCtxt->varsBase];
-                if (getThreadStatus() == XSLDBG_MSG_THREAD_RUN) {
-                    notifyListStart(XSLDBG_MSG_LOCALVAR_CHANGED);
-                    while (item) {
-                        notifyListQueue(item);
-                        item = item->next;
-                    }
-                    notifyListSend();
+            if (styleCtxt->varsNr &&  styleCtxt->varsTab) {
+		if (getThreadStatus() == XSLDBG_MSG_THREAD_RUN) {
+		    notifyListStart(XSLDBG_MSG_LOCALVAR_CHANGED);
+		    for (int i = styleCtxt->varsNr; i > styleCtxt->varsBase; i--) {
+			    xsltStackElemPtr item = styleCtxt->varsTab[i-1];
+			    while (item) {
+				    notifyListQueue(item);
+				    item = item->next;
+			    }
+		    }
+		    notifyListSend();
                 } else {
 		    xmlChar * fullQualifiedName = nodeViewBuffer;
-                    while (item) {		      
-                        if (item->name) {			     
-			    if (item->nameURI == NULL){
-				snprintf((char*)fullQualifiedName, sizeof(nodeViewBuffer), "$%s",
-					 item->name);
-			    }else{
+		    for (int i = styleCtxt->varsNr; i > styleCtxt->varsBase; i--) {
+			    xsltStackElemPtr item = styleCtxt->varsTab[i-1];
+			    while (item) {		      
+				    if (item->name) {			     
+					    if (item->nameURI == NULL){
+						    snprintf((char*)fullQualifiedName, sizeof(nodeViewBuffer), "$%s",
+								    item->name);
+					    }else{
 
-				snprintf((char*)fullQualifiedName, sizeof(nodeViewBuffer), "$%s:%s",
-					 item->nameURI, item->name);
-			    }
-			    if (printVariableValue == 0){
-				xsldbgGenericErrorFunc(i18n(" Local %1").arg(xsldbgText(fullQualifiedName)));
-			    }else{
-			        if (item->computed == 1){
-			           xsldbgGenericErrorFunc(i18n(" Local "));
-			           printXPathObject(item->value, fullQualifiedName);
-			        }else if (item->tree){
-			           xsldbgGenericErrorFunc(i18n(" Local = %1\n").arg(xsldbgText(fullQualifiedName)));
-			           xslDbgCatToFile(item->tree, stderr);
-			        }else if (item->select){
-				  xsldbgGenericErrorFunc(i18n(" Local = %1\n%2").arg(xsldbgText(fullQualifiedName)).arg(xsldbgText(item->select)));
-				}else{
-				  /* can't find a value give only a variable name and an error */
-				  xsldbgGenericErrorFunc(i18n(" Local = %1\n%2").arg(xsldbgText(fullQualifiedName)).arg(i18n("Warning: No value assigned to variable.\n")));
-				}
+						    snprintf((char*)fullQualifiedName, sizeof(nodeViewBuffer), "$%s:%s",
+								    item->nameURI, item->name);
+					    }
+					    if (printVariableValue == 0){
+						    xsldbgGenericErrorFunc(i18n(" Local %1").arg(xsldbgText(fullQualifiedName)));
+					    }else{
+						    if (item->computed == 1){
+							    xsldbgGenericErrorFunc(i18n(" Local "));
+							    printXPathObject(item->value, fullQualifiedName);
+						    }else if (item->tree){
+							    xsldbgGenericErrorFunc(i18n(" Local = %1\n").arg(xsldbgText(fullQualifiedName)));
+							    xslDbgCatToFile(item->tree, stderr);
+						    }else if (item->select){
+							    xsldbgGenericErrorFunc(i18n(" Local = %1\n%2").arg(xsldbgText(fullQualifiedName)).arg(xsldbgText(item->select)));
+						    }else{
+							    /* can't find a value give only a variable name and an error */
+							    xsldbgGenericErrorFunc(i18n(" Local = %1\n%2").arg(xsldbgText(fullQualifiedName)).arg(i18n("Warning: No value assigned to variable.\n")));
+						    }
+					    }
+					    xsltGenericError(xsltGenericErrorContext, "\n\032\032\n");
+				    }
+				    item = item->next;
 			    }
-			    xsltGenericError(xsltGenericErrorContext, "\n\032\032\n");
-			}
-                        item = item->next;
 		    }
                 }
                 result = 1;
diff -x '*.*o*' -x '*.moc' -x Makefile -ur ../old/kdewebdev-3.5.8/kxsldbg/kxsldbgpart/libxsldbg/variable_cmds.cpp kxsldbg/kxsldbgpart/libxsldbg/variable_cmds.cpp
--- kxsldbg/kxsldbgpart/libxsldbg/variable_cmds.cpp	2005-09-10 18:23:15.000000000 +1000
+++ kxsldbg/kxsldbgpart/libxsldbg/variable_cmds.cpp	2008-02-17 18:05:25.000000000 +1000
@@ -60,19 +60,20 @@
             if (name && selectExpr) {
                 xsltStackElemPtr def = NULL;
 
-                if (styleCtxt->varsBase) {
+                if (styleCtxt->varsNr && styleCtxt->varsTab) {
                     /* try finding varaible in stack */
-                    xsltStackElemPtr item =
-                        styleCtxt->varsTab[styleCtxt->varsBase];
-                    while (item) {
-                        if ((xmlStrCmp(name, item->name) == 0) &&
-                            (item->nameURI == NULL
-                             || (xmlStrCmp(name, item->nameURI) == 0))) {
-                            def = item;
-                            break;
-                        }
-                        item = item->next;
-                    }
+		    for (int i = styleCtxt->varsNr; i > styleCtxt->varsBase; i--) {
+			    xsltStackElemPtr item = styleCtxt->varsTab[i-1];
+			    while (item) {
+				    if ((xmlStrCmp(name, item->name) == 0) &&
+						    (item->nameURI == NULL
+						     || (xmlStrCmp(name, item->nameURI) == 0))) {
+					    def = item;
+					    break;
+				    }
+				    item = item->next;
+			    }
+		    }
                 }
 
                 if (def == NULL)

Reply to: