about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation/HTChunk.c
diff options
context:
space:
mode:
Diffstat (limited to 'WWW/Library/Implementation/HTChunk.c')
-rw-r--r--WWW/Library/Implementation/HTChunk.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/WWW/Library/Implementation/HTChunk.c b/WWW/Library/Implementation/HTChunk.c
index a0e1dc95..dc187c3f 100644
--- a/WWW/Library/Implementation/HTChunk.c
+++ b/WWW/Library/Implementation/HTChunk.c
@@ -101,8 +101,9 @@ BOOL HTChunkRealloc(HTChunk *ch, int growby)
 
     ch->allocated = ch->allocated + growby;
 
-    data = ch->data ? (char *) realloc(ch->data, ch->allocated)
-	: typecallocn(char, ch->allocated);
+    data = (ch->data
+	    ? (char *) realloc(ch->data, ch->allocated)
+	    : typecallocn(char, ch->allocated));
 
     if (data) {
 	ch->data = data;
@@ -159,7 +160,7 @@ void HTChunkPutb(HTChunk *ch, const char *b, int l)
     ch->size += l;
 }
 
-#define PUTC(code) ch->data[ch->size++] = (char)(code)
+#define PUTC(code)  ch->data[ch->size++] = (char)(code)
 #define PUTC2(code) ch->data[ch->size++] = (char)(0x80|(0x3f &(code)))
 
 void HTChunkPutUtf8Char(HTChunk *ch, UCode_t code)
@@ -244,11 +245,13 @@ void HTChunkPuts(HTChunk *ch, const char *s)
 {
     const char *p;
 
-    for (p = s; *p; p++) {
-	if (ch->size >= ch->allocated) {
-	    if (!HTChunkRealloc(ch, ch->growby))
-		return;
+    if (s != NULL) {
+	for (p = s; *p; p++) {
+	    if (ch->size >= ch->allocated) {
+		if (!HTChunkRealloc(ch, ch->growby))
+		    return;
+	    }
+	    ch->data[ch->size++] = *p;
 	}
-	ch->data[ch->size++] = *p;
     }
 }