View Issue Details

IDProjectCategoryView StatusLast Update
0000602LDMud 3.3Efunspublic2009-04-14 12:11
Reporterwedsall Assigned Tozesstra  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.3.718 
Target Version3.3.719Fixed in Version3.3.719 
Summary0000602: db_conv_string bugging over 27 characters
DescriptionHello list,
 I'm about to log this into mantis but wanted to post also.

In 3.3.717 I started using the mysql features of ldmud. They've been working well until I upgraded to 3.3.718.

This reboot (using 3.3.718 now) I'm getting bugs with db_conv_string returning strange ascii characters.

Example: db_conv_string("domains/areas/apollo/floor1/entr_castle")
LPC result: " "D
Ô Ô

I will also attach a screenshot.


This seems to happen on any string I use over 27 characters!

lpc db_conv_string("testtesttesttesttesttesttesttesttesttest")
LPC result: ""DP 㵥
testtesttesttesttesttesttesttest"


uuga @ dragonfire
TagsNo tags attached.
Attached Files
example_uugabug.png (12,623 bytes)   
example_uugabug.png (12,623 bytes)   
pkg-mysql.diff (781 bytes)   
Index: pkg-mysql.c
===================================================================
--- pkg-mysql.c	(Revision 2502)
+++ pkg-mysql.c	(Arbeitskopie)
@@ -377,7 +377,8 @@
     char *buff;
 
     s = sp->u.str;
-    buff = xalloc(mstrsize(s)*2 +1);
+    buff = xalloc_with_error_handler(mstrsize(s)*2 +1);
+    // top of stack / inter_sp is now one larger than sp!
     if ( !buff )
     {
         errorf("Out of memory (%zu bytes) in db_conv_string().\n",
@@ -387,9 +388,11 @@
     }
     mysql_escape_string(buff, get_txt(s), strlen(get_txt(s)) );
     
-    xfree(buff);
     free_string_svalue(sp);
     put_c_string(sp, buff);
+    // the error handler is one above sp on the stack.
+    pop_stack();
+    // sp == inter_sp again.
     return sp;
 } /* f_db_conv_string() */
 
pkg-mysql.diff (781 bytes)   

Activities

zesstra

2009-01-17 17:24

administrator   ~0000923

Thanks for your report. Gna. I guess, I found the problem. Could you please try the attached patch and confirm if it works?

wedsall

2009-01-17 18:43

reporter   ~0000925

Trying this on my dev side.


Before patch:
lpc db_conv_string("testytestytestytestytestytestytestytesty")
LPC result: "¼¢ø>


After patch:> lpc db_conv_string("testytestytestytestytestytestytestytesty")
LPC result: "testytestytestytestytestytestytestytesty"


Looks good!

peng

2009-01-17 18:46

reporter   ~0000926

can confirm bug and solution. fast work, zeestra.

zesstra

2009-01-18 06:59

administrator   ~0000927

BTW: the patch from last night was only the quick (and dirty) solution. In rare circumstances it can result in memory leaks. I updated it to use an error handler.
Fixed in r2506.

Issue History

Date Modified Username Field Change
2009-01-17 17:13 wedsall New Issue
2009-01-17 17:13 wedsall File Added: example_uugabug.png
2009-01-17 17:24 zesstra Note Added: 0000923
2009-01-17 17:24 zesstra File Added: pkg-mysql.diff
2009-01-17 18:43 wedsall Note Added: 0000925
2009-01-17 18:46 peng Note Added: 0000926
2009-01-18 03:06 zesstra Assigned To => zesstra
2009-01-18 03:06 zesstra Status new => assigned
2009-01-18 03:06 zesstra Target Version => 3.3.719
2009-01-18 06:49 zesstra File Deleted: pkg-mysql.diff
2009-01-18 06:49 zesstra File Added: pkg-mysql.diff
2009-01-18 06:59 zesstra Note Added: 0000927
2009-01-18 06:59 zesstra Status assigned => resolved
2009-01-18 06:59 zesstra Fixed in Version => 3.3.719
2009-01-18 06:59 zesstra Resolution open => fixed
2009-04-14 12:11 zesstra Project LDMud => LDMud 3.3