Add some sanity assertions to format conversions.
authorNelson Ferreira <nelson.ferreira@ieee.org>
Sun, 15 Jan 2012 03:32:04 +0000 (22:32 -0500)
committerNelson Ferreira <nelson.ferreira@ieee.org>
Sun, 15 Jan 2012 03:32:04 +0000 (22:32 -0500)
* src/buffer.h (TO_EXTERNAL_FORMAT): Add additional assert of
validity after conversion.

* src/buffer.h (TO_INTERNAL_FORMAT): Ditto.

Signed-off-by: Nelson Ferreira <nelson.ferreira@ieee.org>
src/buffer.h

index 4fab508..4c5a81e 100644 (file)
@@ -1099,7 +1099,8 @@ do {                                                                              \
                                  dfc_simplified_sink_type,   &dfc_sink);       \
                                                                                \
   DFC_##sink_type##_USE_CONVERTED_DATA (sink);                                 \
-} while (0)
+} while (0);                                                                   \
+assert((sink)!=NULL)
 
 #define TO_INTERNAL_FORMAT(source_type, source, sink_type, sink, coding_system)        \
 do {                                                                           \
@@ -1130,7 +1131,8 @@ do {                                                                              \
                                  dfc_simplified_sink_type,   &dfc_sink);       \
                                                                                \
   DFC_##sink_type##_USE_CONVERTED_DATA (sink);                                 \
-} while (0)
+} while (0);                                                                   \
+assert((sink)!=NULL)
 
 #ifdef FILE_CODING
 #define DFC_CONVERT_TO_EXTERNAL_FORMAT dfc_convert_to_external_format