Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uwm.edu!zaphod.mps.ohio-state.edu!usc!apple!uokmax!occrsh!S5000!gh From: gh@S5000.UUCP (Sys Admin) Newsgroups: comp.lang.c Subject: Memory Fault Keywords: help Message-ID: <189@S5000.UUCP> Date: 19 Jul 90 14:06:04 GMT Organization: The Quest Glen Lexington, Oklahoma Lines: 55 I got this code from sactoh0!jak (Jay A. Konigsberg) he wrote the simped editor when I run simped and try to put any lines in to the file or read any lines in a existing file I get a core dump This is the Stack Trace from sdb ------------------------------------------------------------------------ Core file 'core' Memory Fault (11) at 14 files, 14 procedures. 0x8319c in strdup:23: buffer[stringinx] = string[stringinx]; >strdup(string="Now is the time.") [strdup.c:23] allocate() addlines(text=0x092d44,overflow=Data address not found > ------------------------------------------------------------------------ This is the code for strdup.c any help is appreciated /* * strdup - duplicate a string using malloc * CODE NOT TESTED, HOWEVER IT SHOULD WORK FINE FOR simped. * =============== */ #include "simped.h" char *strdup(string) char *string; { /*static char *buffer;*/ char *buffer, *malloc(); int stringinx; if (buffer = (char *) malloc(strlen(string)) == NULL) { fprintf(stderr, "malloc: in strdup, error\n"); exit(2); } for (stringinx=0; stringinx <= strlen(string); ++stringinx) buffer[stringinx] = string[stringinx]; return(buffer); } _____________________________________Glen_______________________________________ ______________________________Lexington__Oklahoma_______________________________ ______________________{uunet uunet.uu.net}!uokmax!S5000!gh______________________ -- _____________________________________Glen_______________________________________ ______________________________Lexington__Oklahoma_______________________________ ______________________{uunet uunet.uu.net}!uokmax!S5000!gh______________________