From 2be4cfa78748d0e62c50faa9e37a5982a6f827f0 Mon Sep 17 00:00:00 2001 From: ooxi <85fcd0ef4ec8@f977375cdcd6.anonbox.net> Date: Thu, 1 Nov 2012 02:02:28 +0100 Subject: [PATCH] xml_string_length and xml_string_copy will now accept 0 as string --- CMakeLists.txt | 2 +- src/xml.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d58774..47678b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ PROJECT(xml) SET(VERSION_MAJOR "0") SET(VERSION_MINOR "1") -SET(VERSION_PATCH "1") +SET(VERSION_PATCH "2") CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR) diff --git a/src/xml.c b/src/xml.c index 8d37f56..59cca48 100644 --- a/src/xml.c +++ b/src/xml.c @@ -719,6 +719,9 @@ struct xml_node* xml_node_child(struct xml_node* node, size_t child) { * [PUBLIC API] */ size_t xml_string_length(struct xml_string* string) { + if (!string) { + return 0; + } return string->length; } @@ -728,6 +731,10 @@ size_t xml_string_length(struct xml_string* string) { * [PUBLIC API] */ void xml_string_copy(struct xml_string* string, uint8_t* buffer, size_t length) { + if (!string) { + return; + } + #define min(X,Y) ((X) < (Y) ? (X) : (Y)) length = min(length, string->length); #undef min