Skip to content

Commit

Permalink
Merge pull request JuliaLang#10832 from garrison/fix-10829
Browse files Browse the repository at this point in the history
Fix JuliaLang#10829, freeing of uninitialized pointer
  • Loading branch information
ihnorton committed Apr 17, 2015
2 parents c40bbc6 + ada4654 commit 3cda7a5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/dlload.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,10 @@ DLLEXPORT int jl_uv_dlopen(const char *filename, jl_uv_libhandle lib_, unsigned
#endif
);
if (lib->handle) {
if (lib->errmsg)
free(lib->errmsg);
lib->errmsg = NULL;
return 0;
}
else {
if (lib->errmsg)
free(lib->errmsg);
lib->errmsg = strdup(dlerror());
return -1;
}
Expand Down Expand Up @@ -124,6 +120,10 @@ static uv_lib_t *jl_load_dynamic_library_(const char *modname, unsigned flags, i
snprintf(path, PATHBUF, "%s%s%s", dl_path, modname, ext);
else
snprintf(path, PATHBUF, "%s" PATHSEPSTRING "%s%s", dl_path, modname, ext);
if (handle->errmsg) {
free(handle->errmsg);
handle->errmsg = NULL;
}
error = jl_uv_dlopen(path, handle, flags);
if (!error) goto done;
}
Expand All @@ -136,13 +136,21 @@ static uv_lib_t *jl_load_dynamic_library_(const char *modname, unsigned flags, i
handle->handle = NULL;
/* try loading from standard library path */
snprintf(path, PATHBUF, "%s%s", modname, ext);
if (handle->errmsg) {
free(handle->errmsg);
handle->errmsg = NULL;
}
error = jl_uv_dlopen(path, handle, flags);
if (!error) goto done;
}

#if defined(__linux__) || defined(__FreeBSD__)
{
const char *soname = jl_lookup_soname(modname, strlen(modname));
if (handle->errmsg) {
free(handle->errmsg);
handle->errmsg = NULL;
}
error = (soname==NULL) || jl_uv_dlopen(soname, handle, flags);
if (!error) goto done;
}
Expand Down

0 comments on commit 3cda7a5

Please sign in to comment.