Changeset 07b663c in git


Ignore:
Timestamp:
2006-08-29T11:11:42Z (13 years ago)
Author:
Xuefer <xuefer@…>
Branches:
1.0
Children:
68279dc
Parents:
06b5da4
Message:

avoid crash when OOM on mem_(calloc|realloc|strndup)

git-svn-id: svn://svn.lighttpd.net/xcache/branches/1.0@112 c26eb9a1-5813-0410-bd6c-c2e55f420ca7

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mem.c

    r2d83d9f r07b663c  
    242242    void *p = xc_mem_malloc(mem, realsize);
    243243
    244     memset(p, 0, realsize);
     244    if (p) {
     245        memset(p, 0, realsize);
     246    }
    245247    return p;
    246248}
     
    249251{
    250252    void *newp = xc_mem_malloc(mem, size);
    251     memcpy(newp, p, size);
    252     xc_mem_free(mem, p);
     253    if (p) {
     254        memcpy(newp, p, size);
     255        xc_mem_free(mem, p);
     256    }
    253257    return newp;
    254258}
     
    257261{
    258262    void *p = xc_mem_malloc(mem, len + 1);
    259     memcpy(p, str, len + 1);
     263    if (p) {
     264        memcpy(p, str, len + 1);
     265    }
    260266    return p;
    261267}
Note: See TracChangeset for help on using the changeset viewer.