Permalink
Browse files

Memcpy and attribute value fixes [clang]

(flickcurl_build_location): memcpy instead of strcpy. Always free
attribute value.
  • Loading branch information...
dajobe committed Aug 28, 2012
1 parent 9c1d61e commit f863b4989dc022beb8a4ce4105cf6b26f465ba6a
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/location.c
View
@@ -87,16 +87,19 @@ flickcurl_build_location(flickcurl* fc, xmlXPathContextPtr xpathCtx,
for(attr = node->properties; attr; attr = attr->next) {
const char *attr_name = (const char*)attr->name;
char *attr_value;
-
- attr_value = (char*)malloc(strlen((const char*)attr->children->content)+1);
- strcpy(attr_value, (const char*)attr->children->content);
+ size_t attr_value_len = strlen((const char*)attr->children->content);
+
+ attr_value = (char*)malloc(attr_value_len + 1);
+ memcpy(attr_value, attr->children->content, attr_value_len + 1);
if(!strcmp(attr_name, "latitude"))
location->latitude = atoi(attr_value);
else if(!strcmp(attr_name, "longitude"))
location->longitude = atoi(attr_value);
else if(!strcmp(attr_name, "accuracy"))
location->accuracy = atoi(attr_value);
+
+ free(attr_value);
}

0 comments on commit f863b49

Please sign in to comment.