Bug#306042: dia: Please include patch to fix another crash with line wrapping code

Hervé Cauwelier HervĂ© Cauwelier <hcauwelier@oursours.net>, 306042@bugs.debian.org
Sun, 24 Apr 2005 00:02:03 +0200


This is a multi-part message in MIME format.
--------------020706080202000506020500
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit

Package: dia
Severity: wishlist
Tags: patch

Quoting Hans Breuer  <hans@breuer.org>:

"* objects/UML/class.c : fix another crash with the line
   wrapping code (Gabor Simon, bug #160865)"

The change is attached as a dpatch file.

I don't think this is related to your bug #192436.

-- 
Hervé Cauwelier
http://www.oursours.net/

--------------020706080202000506020500
Content-Type: text/plain;
 name="04_fix-another-crash-with-line-wrapping-code.dpatch"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline;
 filename="04_fix-another-crash-with-line-wrapping-code.dpatch"

#! /bin/sh /usr/share/dpatch/dpatch-run
## 04_fix-another-crash-with-line-wrapping-code.dpatch by Hervé Cauwelier <hcauwelier@oursours.net>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad dia-0.94.0/objects/UML/class.c /tmp/dpep.qXOySX/dia-0.94.0/objects/UML/class.c
--- dia-0.94.0/objects/UML/class.c	2005-04-19 22:40:28.000000000 +0200
+++ /tmp/dpep.qXOySX/dia-0.94.0/objects/UML/class.c	2005-04-23 20:27:00.637842608 +0200
@@ -507,14 +507,13 @@
                              &umlclass->line_color);
     if (!umlclass->suppress_operations) {
       GList *wrapsublist = NULL;
-      gchar *part_opstr;
+      gchar *part_opstr = NULL;
       int wrap_pos, last_wrap_pos, ident, wrapping_needed;
+      int part_opstr_len = 0, part_opstr_need = 0;
 
       p.x = x + UMLCLASS_BORDER/2.0 + 0.1;
       p.y = p1.y + 0.1;
 
-      part_opstr = g_alloca (umlclass->max_wrapped_line_width);
-
       i = 0;
       list = umlclass->operations;
       while (list != NULL) {
@@ -556,9 +555,19 @@
             wrap_pos = GPOINTER_TO_INT( wrapsublist->data);
             
             if( last_wrap_pos == 0) {
+              part_opstr_need = wrap_pos + 1;
+              if (part_opstr_len < part_opstr_need) {
+                part_opstr_len = part_opstr_need;
+                part_opstr = g_realloc (part_opstr, part_opstr_need);
+              }
               strncpy( part_opstr, opstr, wrap_pos);  
               memset( part_opstr+wrap_pos, '\0', 1);
             } else {  
+              part_opstr_need = ident + wrap_pos - last_wrap_pos + 1;
+              if (part_opstr_len < part_opstr_need) {
+                part_opstr_len = part_opstr_need;
+                part_opstr = g_realloc (part_opstr, part_opstr_need);
+              }
               memset( part_opstr, ' ', ident);
               memset( part_opstr+ident, '\0', 1);
               strncat( part_opstr, opstr+last_wrap_pos, wrap_pos-last_wrap_pos);                
@@ -621,6 +630,9 @@
         list = g_list_next(list);
         i++;
       }
+      if (part_opstr) {
+        g_free(part_opstr);
+      }
     }
   }
 


--------------020706080202000506020500--