l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
September 2: Social gathering
Next Installfest:
TBD
Latest News:
Aug. 18: Discounts to "Velocity" in NY; come to tonight's "Photography" talk
Page last updated:
2002 Feb 02 01:39

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] RE: vox-tech digest, Vol 1 #104 - 14 msgs
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] RE: vox-tech digest, Vol 1 #104 - 14 msgs



On Fri, 1 Feb 2002, Ken Bloom wrote:

> > -----Original Message-----
> > Date: Thu, 31 Jan 2002 23:25:47 -0800 (PST)
> > From: Jeff Newmiller <jdnewmil@dcn.davis.ca.us>
> > To: vox-tech@lists.lugod.org
> > Subject: Re: [vox-tech] [C newbie]C program is acting weird...
> > Reply-To: vox-tech@lists.lugod.org
> >
> > On Thu, 31 Jan 2002, Ryan wrote:
> >
> > > -----BEGIN PGP SIGNED MESSAGE-----
> > > Hash: SHA1
> > >
> > > for some reason this is spitting out 3 char responses once in a
> > while, anyone
> > > have any ideas? I don't know much C, this is just some code I modified.

[...]

> > > char *randusername()
> > > {
> > >         char *string;
> >
> > You have not initialized space to put the characters that this string
> > points to, so you are putting them in, ah, unpredictable locations in
> > memory.  The behavior of the program after you write to string[0] is
> > undefined. I would recommend "static char string[ MAX_LEN+1 ]".

[...]

> > >         if (string = malloc(length + 2), string == NULL)
> > >                 return NULL;
> 
> Why do you assume he doesn't know what he's doing with that char* string.
> Did you look farther down to see the malloc()? If he changed the code as you
> suggest, it would break instantly.

Mea culpa.  Sorry!

---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil@dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...2k
---------------------------------------------------------------------------

_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Sunset Systems
Who graciously hosts our website & mailing lists!