Changeset 529


Ignore:
Timestamp:
Aug 5, 2003, 12:16:47 PM (22 years ago)
Author:
bird
Message:

A couple of memory related bugfixes.

Location:
trunk/src/emx/src/emxomf
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/emx/src/emxomf/emxomfld.c

    • Property cvs2svn:cvs-rev changed from 1.18 to 1.19
    r528 r529  
    200200
    201201  p = malloc (n);
    202   if (p == NULL)
     202  if (p == NULL && n)
    203203    {
    204204      fprintf (stderr, "emxomfld: out of memory\n");
     
    218218
    219219  p = realloc (ptr, n);
    220   if (p == NULL)
     220  if (p == NULL && n)
    221221    {
    222222      fprintf (stderr, "emxomfld: out of memory\n");
     
    235235{
    236236  char *p;
    237 
    238   p = xmalloc (strlen (s) + 1);
    239   strcpy (p, s);
     237  int cch = strlen (s) + 1;
     238
     239  p = xmalloc (cch);
     240  memcpy (p, s, cch);
    240241  return p;
    241242}
     
    825826      /* add argument to argument vector. */
    826827      if (!(argi % 32))
    827         argv = xrealloc(argv, argi + 32 + 1);
     828        argv = xrealloc(argv, sizeof(argv[0]) * (argi + 32 + 1));
    828829      argv[argi++] = xstrdup(psz);
    829830
  • TabularUnified trunk/src/emx/src/emxomf/weakld.c

    • Property cvs2svn:cvs-rev changed from 1.10 to 1.11
    r528 r529  
    21612161                    /* put into array of externals */
    21622162                    if (!(cExts % 64))
    2163                     {
    2164                         cExts += 64;
    2165                         papExts = xrealloc(papExts, sizeof(papExts[0]) * cExts);
    2166                     }
     2163                        papExts = xrealloc(papExts, sizeof(papExts[0]) * (cExts + 64));
    21672164                    papExts[cExts++] = pSym;
    21682165                }
Note: See TracChangeset for help on using the changeset viewer.