[Crossfire-wiki] [Crossfire DokuWiki] page changed: user:mhoram:code:bwp

no-reply_wiki at metalforge.org no-reply_wiki at metalforge.org
Wed Jan 17 07:24:05 CST 2007


A page in your DokuWiki was added or changed. Here are the details:

Date        : 2007/01/17 07:24
User        : ryo
Edit Summary: some more

@@ -5,11 +5,12 @@
  The main problem I'm having right now is that a couple variables are getting clobbered; I assume by bad memory allocation.  It happens at line 502: the variables *key[] and *val[] are fine before that call to join_with_comma(), but after it they are messed up.  (Search for BEFORE and AFTER.)  Since they aren't involved in that function at all, I assume that something in that function is causing an overflow.  There's probably a way with gdb or some other tool to see what variable is using a particular memory address, but I don't know what it is. 
  
  Also, if anyone knows of a good C primer/tutorial online, please let me know.
  
- In the sortbyname, a and b will be const char* *, not char*, thus you need to dereference them => ''strcpy(aa,(*(const char* *)a));'' or something like that :)
- 
- Also, to compare, try ''strcasecmp'' which does case-insensitive comparison.
+   * In the sortbyname, a and b will be const char* *, not char*, thus you need to dereference them => ''strcpy(aa,(*(const char* *)a));'' or something like that :)
+   * Also, to compare, try ''strcasecmp'' which does case-insensitive comparison.
+   * ''append_with_comma'' (not used, but just in case) has a side effect: old will be destroyed if not NULL - the ''realloc'' can make the original pointer (which still exists probably) point to a freed memory.
+   * and some day don't forget to ''free()'' allocated memory (for the char* and such) ^_-
  
  ===== Notes & Comments =====
  
  


IP-Address  : 196.3.55.241
Old Revision: http://wiki.metalforge.net/doku.php/user:mhoram:code:bwp?rev=1169038974
New Revision: http://wiki.metalforge.net/doku.php/user:mhoram:code:bwp

-- 
This mail was generated by DokuWiki at
http://wiki.metalforge.net/




More information about the crossfire-wiki mailing list