Well, I haven't had this problem yet (mainly because I despise strdup()) but I can see that it is definitely an issue to be dealt with. I looked a proc_color() and I found that the last lines were this. out_buf[p] = '\0'; strcpy(inbuf, out_buf); Now if inbuf is smaller than outbuf this _will_ cause a seg fault. here is my solution: out_buf[p] = '\0'; realloc(inbuf, (strlen(outbuf) * sizeof(char)) + sizeof(char) ); strcpy(inbuf, out_buf); That, I believe, should make sure that inbuf is as big as outbuf. Good luck. --Sean ------------------------ Sorren@usa.net[SMTP:sorren@MUDMUD.COM] Here's what I believe to be the problem I am having, I have a string that I sprintf to, like sprintf(buf,"&RHello world&w"); with the color codes in, then if I do a str_dup, or manipulate it, I get out of bounds problems and all other sorts of fun memory over running problems, I THINK its from, When the string is allocated, its allocated for 15 chars, including the &w and &R. Then when its actually printed out, or passed through the proc_color, the &R is now replaced with the acutal ansi code for changing the color which is quite larger then &R. So, as you can see, when its free and such I get problems, I was wondering if anyone else has encountered this problem, and knows how to fix it ? Sorren +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+ +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST