summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Beckett <dave@dajobe.org>2014-10-26 20:39:05 -0700
committerDave Beckett <dave@dajobe.org>2014-10-26 20:40:46 -0700
commit07037dd16f4c167349dc1e136c76e084eafd6df6 (patch)
treec937cae98b8f2d712b7197b3787bc6ef486de06e
parente44eac50d51809f7ab6caf122cac80e0adb58c8b (diff)
downloadraptor-07037dd16f4c167349dc1e136c76e084eafd6df6.tar.gz
Fix return values for raptor_iostream_{hexa,}decimal_write
(raptor_iostream_decimal_write, raptor_iostream_hexadecimal_write): Return non-0 if number of objects returned from raptor_iostream_write_bytes() does not match expected length. Fixes Issue #0000575 http://bugs.librdf.org/mantis/view.php?id=575
-rw-r--r--src/raptor_iostream.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/raptor_iostream.c b/src/raptor_iostream.c
index 9e605e65..1d41f0ea 100644
--- a/src/raptor_iostream.c
+++ b/src/raptor_iostream.c
@@ -882,6 +882,8 @@ raptor_iostream_decimal_write(int integer, raptor_iostream* iostr)
unsigned char *p;
int i = integer;
size_t length = 1;
+ int nobj;
+
if(integer < 0) {
length++;
i= -integer;
@@ -900,7 +902,8 @@ raptor_iostream_decimal_write(int integer, raptor_iostream* iostr)
if(integer < 0)
*p= '-';
- return raptor_iostream_write_bytes(buf, 1, length, iostr);
+ nobj = raptor_iostream_write_bytes(buf, 1, length, iostr);
+ return (RAPTOR_BAD_CAST(size_t, nobj) != length);
}
@@ -921,7 +924,7 @@ raptor_iostream_hexadecimal_write(unsigned int integer, int width,
raptor_iostream* iostr)
{
char *buf;
- int rc;
+ int nobj;
if(width < 1)
return 1;
@@ -933,9 +936,9 @@ raptor_iostream_hexadecimal_write(unsigned int integer, int width,
(void)raptor_format_integer(buf, width + 1, integer, /* base */ 16,
width, '0');
- rc = raptor_iostream_write_bytes(buf, 1, width, iostr);
+ nobj = raptor_iostream_write_bytes(buf, 1, width, iostr);
RAPTOR_FREE(char*, buf);
- return rc;
+ return (nobj != width);
}