Fix a few small memleaks

This commit is contained in:
Iwan Timmer
2015-08-14 15:23:40 +02:00
parent 01466c9bb9
commit dee2231bf2
4 changed files with 29 additions and 10 deletions

View File

@@ -350,7 +350,6 @@ int gs_pair(PSERVER_DATA server, char* pin) {
if ((ret = http_request(url, data)) != GS_OK)
goto cleanup;
printf("Paired\n");
server->paired = true;
cleanup:

View File

@@ -23,6 +23,8 @@
#include <expat.h>
#include <string.h>
static XML_Parser parser;
struct xml_query {
char *memory;
size_t size;
@@ -103,11 +105,15 @@ int xml_search(char* data, size_t len, char* node, char** result) {
if (! XML_Parse(parser, data, len, 1)) {
int code = XML_GetErrorCode(parser);
gs_error = XML_ErrorString(code);
XML_ParserFree(parser);
free(search.memory);
return GS_INVALID;
} else if (search.memory == NULL)
} else if (search.memory == NULL) {
XML_ParserFree(parser);
return GS_OUT_OF_MEMORY;
}
XML_ParserFree(parser);
*result = search.memory;
return GS_OK;
@@ -126,8 +132,11 @@ int xml_applist(char* data, size_t len, PAPP_LIST *app_list) {
if (! XML_Parse(parser, data, len, 1)) {
int code = XML_GetErrorCode(parser);
gs_error = XML_ErrorString(code);
XML_ParserFree(parser);
return GS_INVALID;
}
XML_ParserFree(parser);
*app_list = (PAPP_LIST) query.data;
return GS_OK;