Commit 2239e280 authored by Petri Hintukainen's avatar Petri Hintukainen

file: check for memory allocation failures

parent 8e47016f
......@@ -65,6 +65,10 @@ static BD_DIR_H *_dir_open_posix(const char* dirname)
BD_DIR_H *dir = calloc(1, sizeof(BD_DIR_H));
BD_DEBUG(DBG_DIR, "Opening POSIX dir %s... (%p)\n", dirname, (void*)dir);
if (!dir) {
return NULL;
}
dir->close = _dir_close_posix;
dir->read = _dir_read_posix;
......
......@@ -75,6 +75,9 @@ static BD_DIR_H *_dir_open_win32(const char* dirname)
BD_DIR_H *dir = calloc(1, sizeof(BD_DIR_H));
BD_DEBUG(DBG_DIR, "Opening WIN32 dir %s... (%p)\n", dirname, (void*)dir);
if (!dir) {
return NULL;
}
dir->close = _dir_close_win32;
dir->read = _dir_read_win32;
......
......@@ -98,6 +98,9 @@ const char *file_get_config_system(const char *dir)
if (xdg_sys && *xdg_sys) {
dirs = calloc(1, strlen(xdg_sys) + 2);
if (!dirs) {
return NULL;
}
strcpy(dirs, xdg_sys);
char *pt = dirs;
......
......@@ -81,6 +81,11 @@ void *dl_dlopen(const char *path, const char *version)
name = str_printf("%s%s%s", search_paths[i], path, ext);
}
if (!name) {
BD_DEBUG(DBG_FILE | DBG_CRIT, "out of memory\n");
continue;
}
BD_DEBUG(DBG_FILE, "Attempting to open %s\n", name);
dll = _dl_dlopen (name);
......
......@@ -62,6 +62,11 @@ void *dl_dlopen(const char *path, const char *version)
void *result;
name = str_printf("%s.dll", path);
if (!name) {
BD_DEBUG(DBG_FILE | DBG_CRIT, "out of memory\n");
return NULL;
}
MultiByteToWideChar(CP_UTF8, 0, name, -1, wname, MAX_PATH);
X_FREE(name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment