~ubuntu-branches/ubuntu/trusty/patch/trusty-security

« back to all changes in this revision

Viewing changes to lib/xmalloc.c

  • Committer: Package Import Robot
  • Author(s): Christoph Berg
  • Date: 2013-01-03 17:34:45 UTC
  • mto: (6.1.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20130103173445-5vf8qmnfgd7ug67h
Tags: upstream-2.7.1
ImportĀ upstreamĀ versionĀ 2.7.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* xmalloc.c -- malloc with out of memory checking
2
2
 
3
 
   Copyright (C) 1990-2000, 2002-2006, 2008-2011 Free Software Foundation, Inc.
 
3
   Copyright (C) 1990-2000, 2002-2006, 2008-2012 Free Software Foundation, Inc.
4
4
 
5
5
   This program is free software: you can redistribute it and/or modify
6
6
   it under the terms of the GNU General Public License as published by
52
52
void *
53
53
xrealloc (void *p, size_t n)
54
54
{
 
55
  if (!n && p)
 
56
    {
 
57
      /* The GNU and C99 realloc behaviors disagree here.  Act like
 
58
         GNU, even if the underlying realloc is C99.  */
 
59
      free (p);
 
60
      return NULL;
 
61
    }
 
62
 
55
63
  p = realloc (p, n);
56
 
  if (!p && n != 0)
 
64
  if (!p && n)
57
65
    xalloc_die ();
58
66
  return p;
59
67
}