diff options
author | Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com> | 2015-03-03 12:44:46 +0100 |
---|---|---|
committer | Mohamad Ayyash <mkayyash@google.com> | 2015-03-06 17:58:34 -0800 |
commit | eb433fd28ce3ce814fabfb945bf330faf3193f1d (patch) | |
tree | 8c68b0811f0c2306e8582aecd2d83c6fc5f3a797 | |
parent | 0dfdb89c227ba8d2578a9284eca49ed080134654 (diff) | |
download | fio-eb433fd28ce3ce814fabfb945bf330faf3193f1d.tar.gz |
fio: fix smalloc strdop allocation failure
smalloc_strdup didn't check for allocation success and thereby ran into
segfaults if the single pool went out of memory.
Now with this patch applied it is still failing, but in a more consistent
way than segfaulting.
You still get a bad allocation, but it looks like this now:
fio: smalloc OOM
fio: filesetup.c:1495: dup_files: Assertion `0' failed.
Aborted
In fact the upper layers expected smalloc_strdup to retrun NULL on failure.
Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r-- | smalloc.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -492,9 +492,10 @@ void *scalloc(size_t nmemb, size_t size) char *smalloc_strdup(const char *str) { - char *ptr; + char *ptr = NULL; ptr = smalloc(strlen(str) + 1); - strcpy(ptr, str); + if (ptr) + strcpy(ptr, str); return ptr; } |