Fix incorrect "pos=0" pdml values. Resolves the issue reported in comment 4 of https...
[obnox/wireshark/wip.git] / print.c
diff --git a/print.c b/print.c
index 876b04d02f7709b39bc6ebd8e1d221d4b204f8b2..950e13924e155a64d1f314deace7e59129580e7c 100644 (file)
--- a/print.c
+++ b/print.c
@@ -336,7 +336,11 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data)
                print_escaped_xml(pdata->fh, label_ptr);
 
                fprintf(pdata->fh, "\" size=\"%d", fi->length);
-               fprintf(pdata->fh, "\" pos=\"%d", fi->start);
+               if (node->parent && node->parent->finfo && (fi->start < node->parent->finfo->start)) {
+                       fprintf(pdata->fh, "\" pos=\"%d", node->parent->finfo->start + fi->start);
+               } else {
+                       fprintf(pdata->fh, "\" pos=\"%d", fi->start);
+               }
 
                fputs("\" value=\"", pdata->fh);
                write_pdml_field_hex_value(pdata, fi);
@@ -401,7 +405,11 @@ proto_tree_write_node_pdml(proto_node *node, gpointer data)
                        fprintf(pdata->fh, "\" hide=\"yes");
 
                fprintf(pdata->fh, "\" size=\"%d", fi->length);
-               fprintf(pdata->fh, "\" pos=\"%d", fi->start);
+               if (node->parent && node->parent->finfo && (fi->start < node->parent->finfo->start)) {
+                       fprintf(pdata->fh, "\" pos=\"%d", node->parent->finfo->start + fi->start);
+               } else {
+                       fprintf(pdata->fh, "\" pos=\"%d", fi->start);
+               }
 /*             fprintf(pdata->fh, "\" id=\"%d", fi->hfinfo->id);*/
 
                /* show, value, and unmaskedvalue attributes */