diff options
author | bptato <nincsnevem662@gmail.com> | 2024-08-17 16:57:18 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-08-17 16:57:18 +0200 |
commit | 30920fe12cbc6ab72078a68e308931bf865ede26 (patch) | |
tree | bb93a23bae417bb6196a634dab238628bffadebd /src/loader | |
parent | f5f841dc7528098c2a07bd06280fa9d1c4ea3164 (diff) | |
download | chawan-30920fe12cbc6ab72078a68e308931bf865ede26.tar.gz |
loader: fix crash on empty data URLs
Diffstat (limited to 'src/loader')
-rw-r--r-- | src/loader/loader.nim | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/loader/loader.nim b/src/loader/loader.nim index c9025153..c40c3cad 100644 --- a/src/loader/loader.nim +++ b/src/loader/loader.nim @@ -414,10 +414,17 @@ proc loadDataSend(ctx: LoaderContext; handle: LoaderHandle; s, ct: string) = handle.sendResult(0) handle.sendStatus(200) handle.sendHeaders(newHeaders({"Content-Type": ct})) + let output = handle.output + if s.len == 0: + if output.suspended: + output.istreamAtEnd = true + ctx.outputMap[output.ostream.fd] = output + else: + output.oclose() + return let buffer = newLoaderBuffer(size = s.len) buffer.len = s.len copyMem(buffer.page, unsafeAddr s[0], s.len) - let output = handle.output case ctx.pushBuffer(output, buffer, 0) of pbrUnregister: if output.registered: |