[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: gEDA-user: Removing My* memory alllocation functions
On Wed, Dec 8, 2010 at 4:51 AM, Peter Clifton <pcjc2@xxxxxxxxx> wrote:
> Stephen, I'd appreciate your Acked-by: or Reviewed-by: on the attached
> patches:
Patch 0001 is good, but I can suggest some additional MyStrdup() calls
that can safely be directly replaced with strdup():
create.c
196: safe because DefaultLayerName array properly initialised in
main.c and safely updated in hid/gtk/gui-config.c
593: safe, because CreateNewText() should never be called with NULL.
If it is, a segfault would aid debugging.
789: I suggest it is safe. A pin should always have a number. Better
to segfault than create a pin with Number==NULL
876: I suggest it is safe. A pad should always have a number. Better
to segfault than create a pad with Number==NULL
900: I suggest it is safe. Better to segfault than create a text
object with text==NULL
1013: safe. Only called from ActionElementSetAttr(), protected by
(argc <2) check
1014: safe. Only called from ActionElementSetAttr(), protected by
(argc <2) check
file.c
321: Safe. A null pointer would cause WritePipe() to return an error,
causing MyStrdup() to be avoided.
393: Safe. NULL Filename would be caught by ParsePCB(), causing
MyStrdup() to be avoided.
1169: Safe. A null pointer would segfault in pcb_basename()'s call to
strchr() before MyStrdup reached.
1260: Safe. Settings.LibraryTree initialised to non NULL in main.c and
kept valid in hid/gtk/gui-top-window.c and hid/gtk/gui-config.c
1923: I suggest it is safe. An attribute should at least have a name.
Better to segfault than create an attribute with no name.
rats.c
924: Safe. Called with character array.
942: Safe. Called with character array.
944: Safe. Called with character array.
915 and 946 are also safe because of the code flow:
found=SearchObjectByLocation (PAD_TYPE | PIN_TYPE, ...)
[...]
if (found == NO_TYPE)
return (NULL);
[...]
name2 = ConnectionName (found, ptr1, ptr2);
It follows that name2 always points to character array "static char
name[256];" at line 962
Some of these suggestions are slightly speculative, I suggest that you
reject any that you aren't comfortable with - better to have a few
unnecessary call to your MYSTRDUP() macro than to possibly brake
existing code.
Patch 0002: I'll run my own mechanical conversion and check that we
generate identical diffs. I'll let you know when I'm finished.
_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user