Commit ea9de083 authored by sletz's avatar sletz
Browse files

Better memory allocation error checking on client (library) side.

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@3768 0c269be4-1314-0410-8aa9-9f06e86f4224
parent 7a39e868
......@@ -25,7 +25,11 @@ Paul Davis
Jackdmp changes log
---------------------------
2009-11-10 Stephane Letz <letz@grame.fr>
2009-11-12 Stephane Letz <letz@grame.fr>
* Better memory allocation error checking on client (library) side.
2009-11-11 Stephane Letz <letz@grame.fr>
* Correct JackCoreAudio driver when empty strings are given as -C, -P or -d parameter.
......
......@@ -1943,5 +1943,7 @@ jack_get_version_string()
EXPORT void jack_free(void* ptr)
{
free(ptr);
if (ptr) {
free(ptr);
}
}
......@@ -988,14 +988,7 @@ char* JackClient::GetInternalClientName(int ref)
char name_res[JACK_CLIENT_NAME_SIZE + 1];
int result = -1;
fChannel->GetInternalClientName(GetClientControl()->fRefNum, ref, name_res, &result);
if (result < 0) {
return NULL;
} else {
char* name = (char*)malloc(strlen(name_res));
strcpy(name, name_res);
return name;
}
return (result < 0) ? NULL : strdup(name_res);
}
int JackClient::InternalClientHandle(const char* client_name, jack_status_t* status)
......
......@@ -702,6 +702,9 @@ const char** JackGraphManager::GetConnections(jack_port_id_t port_index)
{
const char** res = (const char**)malloc(sizeof(char*) * CONNECTION_NUM_FOR_PORT);
UInt16 cur_index, next_index;
if (!res)
return NULL;
do {
cur_index = GetCurrentIndex();
......@@ -782,6 +785,9 @@ const char** JackGraphManager::GetPorts(const char* port_name_pattern, const cha
{
const char** res = (const char**)malloc(sizeof(char*) * PORT_NUM);
UInt16 cur_index, next_index;
if (!res)
return NULL;
do {
cur_index = GetCurrentIndex();
......
......@@ -48,8 +48,10 @@ jack_slist_alloc (void)
JSList *new_list;
new_list = (JSList*)malloc(sizeof(JSList));
new_list->data = NULL;
new_list->next = NULL;
if (new_list) {
new_list->data = NULL;
new_list->next = NULL;
}
return new_list;
}
......@@ -61,8 +63,10 @@ jack_slist_prepend (JSList* list, void* data)
JSList *new_list;
new_list = (JSList*)malloc(sizeof(JSList));
new_list->data = data;
new_list->next = list;
if (new_list) {
new_list->data = data;
new_list->next = list;
}
return new_list;
}
......
Supports Markdown
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