summaryrefslogtreecommitdiff
path: root/cord
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2016-09-28 10:27:12 +0300
committerIvan Maidanski <ivmai@mail.ru>2016-09-28 10:27:12 +0300
commitcbc51ee1f71cb0007ac70adae48b05e26ab83f39 (patch)
tree86dc916faf8ae9bb03a811aaa6b47d1f7badd6eb /cord
parent6783d150effd76f4e77111672ba6ba2c74e024d1 (diff)
downloadbdwgc-cbc51ee1f71cb0007ac70adae48b05e26ab83f39.tar.gz
Fix CORD_substr_closure for the case when CORD_from_fn returns C string
* cord/cordbscs.c (CORD_substr_closure): Change type of "result" local variable from CORD to CordRep* (insert necessary type casts); update function.header only if function.null field is zero (i.e. CORD_from_fn returned pointer to CordRep, not a pointer to C character string).
Diffstat (limited to 'cord')
-rw-r--r--cord/cordbscs.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/cord/cordbscs.c b/cord/cordbscs.c
index d6c33ee9..321ca94d 100644
--- a/cord/cordbscs.c
+++ b/cord/cordbscs.c
@@ -352,15 +352,15 @@ char CORD_apply_access_fn(size_t i, void * client_data)
CORD CORD_substr_closure(CORD x, size_t i, size_t n, CORD_fn f)
{
register struct substr_args * sa = GC_NEW(struct substr_args);
- CORD result;
+ CordRep * result;
if (sa == 0) OUT_OF_MEMORY;
sa->sa_cord = (CordRep *)x;
sa->sa_index = i;
- result = CORD_from_fn(f, (void *)sa, n);
- if (result == CORD_EMPTY) return CORD_EMPTY; /* n == 0 */
- ((CordRep *)result) -> function.header = SUBSTR_HDR;
- return (result);
+ result = (CordRep *)CORD_from_fn(f, (void *)sa, n);
+ if ((CORD)result != CORD_EMPTY && 0 == result -> function.null)
+ result -> function.header = SUBSTR_HDR;
+ return (CORD)result;
}
# define SUBSTR_LIMIT (10 * SHORT_LIMIT)