/*********************************************************
- * Copyright (C) 2010-2018 VMware, Inc. All rights reserved.
+ * Copyright (C) 2010-2019 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
/*
* If not a continuation line and we have a name, break out of the
- * inner loop to update the dictionaty.
+ * inner loop to update the dictionary.
*/
if (!cont && name != NULL) {
g_free(line);
}
if (error) {
+ free(name);
+ free(value);
break;
}
!Unicode_IsBufferValid(value, strlen(value) + 1, STRING_ENCODING_UTF8)) {
g_warning("Invalid UTF-8 string in message catalog (key = %s)\n", name);
error = TRUE;
+ free(name);
+ free(value);
break;
}
HashTable_ReplaceOrInsert(dict, name, g_strdup(value));
free(name);
free(value);
- name = NULL;
- value = NULL;
}
if (eof) {
/*********************************************************
- * Copyright (C) 2011-2018 VMware, Inc. All rights reserved.
+ * Copyright (C) 2011-2019 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
g_free,
g_free);
for (;;) {
- gboolean eof = FALSE;
char *name = NULL;
char *value = NULL;
gchar *line;
}
if (line == NULL) {
- eof = TRUE;
+ /* This signifies EOF. */
break;
}
g_free(line);
if (error) {
+ /*
+ * If the local DictLL_UnmarshalLine() returns NULL, name and value
+ * will remain NULL pointers. No malloc'ed memory to free here.
+ */
break;
}
!g_utf8_validate(value, -1, NULL)) {
g_warning("Invalid UTF-8 string in message catalog (key = %s)\n", name);
error = TRUE;
+ g_free(name);
+ g_free(value);
break;
}
val = g_strcompress(value);
g_free(value);
- // the hashtable takes ownership of the memory for 'name' and 'value'
+ // the hashtable takes ownership of the memory for 'name' and 'val'
g_hash_table_insert(dict, name, val);
- name = NULL;
- value = NULL;
- }
-
- if (eof) {
- break;
}
}