mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-02-16 02:20:42 +00:00
Fix a few small memleaks
This commit is contained in:
14
src/config.c
14
src/config.c
@@ -83,22 +83,26 @@ char* get_path(char* name, char* extra_data_dirs) {
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
char* data_dir = data_dirs;
|
||||
char* end;
|
||||
do {
|
||||
end = strstr(data_dirs, ":");
|
||||
int length = end != NULL?end - data_dirs:strlen(data_dirs);
|
||||
memcpy(path, data_dirs, length);
|
||||
end = strstr(data_dir, ":");
|
||||
int length = end != NULL?end - data_dir:strlen(data_dir);
|
||||
memcpy(path, data_dir, length);
|
||||
if (path[0] == '/')
|
||||
sprintf(path+length, MOONLIGHT_PATH "/%s", name);
|
||||
else
|
||||
sprintf(path+length, "/%s", name);
|
||||
|
||||
if(access(path, R_OK) != -1)
|
||||
if(access(path, R_OK) != -1) {
|
||||
free(data_dirs);
|
||||
return path;
|
||||
}
|
||||
|
||||
data_dirs = end + 1;
|
||||
data_dir = end + 1;
|
||||
} while (end != NULL);
|
||||
|
||||
free(data_dirs);
|
||||
free(path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
13
src/main.c
13
src/main.c
@@ -190,9 +190,16 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
SERVER_DATA server;
|
||||
server.address = config.address;
|
||||
if (gs_init(&server, config.key_dir) != GS_OK) {
|
||||
fprintf(stderr, "Can't connect to server %s\n", config.address);
|
||||
exit(-1);
|
||||
int ret;
|
||||
if ((ret = gs_init(&server, config.key_dir)) == GS_OUT_OF_MEMORY) {
|
||||
fprintf(stderr, "Not enough memory\n");
|
||||
exit(-1);
|
||||
} else if (ret == GS_INVALID) {
|
||||
fprintf(stderr, "Invalid data received from server: %s\n", config.address, gs_error);
|
||||
exit(-1);
|
||||
} else if (ret != GS_OK) {
|
||||
fprintf(stderr, "Can't connect to server %s\n", config.address);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
if (strcmp("list", config.action) == 0) {
|
||||
|
||||
Reference in New Issue
Block a user