summaryrefslogtreecommitdiff
path: root/dev-libs/nanomsg/files/nanomsg-1.2.1-chunk.patch
blob: 7d6cec72593903bd9d57f6057f0ecda2c9cedcd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
https://bugs.gentoo.org/934665
https://github.com/nanomsg/nanomsg/issues/1111#issuecomment-2113151297
(acked by upstream at https://github.com/nanomsg/nanomsg/issues/1111#issuecomment-2305516234)

--- a/src/utils/chunkref.c
+++ b/src/utils/chunkref.c
@@ -52,6 +52,7 @@
 {
     if (self->size == NN_CHUNKREF_EXT) {
         nn_chunk_free (self->u.chunk);
+        self->size = 0;
     }
 }
 
@@ -80,6 +81,8 @@
     dst->size = src->size;
     if (src->size == NN_CHUNKREF_EXT) {
         dst->u.chunk = src->u.chunk;
+        // self->u.chunk = NULL;
+        // src->size = 0;
     } else {
         nn_assert (src->size <= NN_CHUNKREF_MAX);
         memcpy (dst->u.ref, src->u.ref, src->size);
@@ -100,7 +103,7 @@
 
 void *nn_chunkref_data (struct nn_chunkref *self)
 {
-    if (self->size > NN_CHUNKREF_MAX) {
+    if (self->size == NN_CHUNKREF_EXT) {
         return self->u.chunk;
     } else {
         return self->u.ref;
@@ -109,7 +112,7 @@
 
 size_t nn_chunkref_size (struct nn_chunkref *self)
 {
-    if (self->size > NN_CHUNKREF_MAX) {
+    if (self->size == NN_CHUNKREF_EXT) {
         return (nn_chunk_size(self->u.chunk));
     }
     return self->size;
@@ -118,7 +121,7 @@
 void nn_chunkref_trim (struct nn_chunkref *self, size_t n)
 {
     if (self->size == NN_CHUNKREF_EXT) {
-        nn_chunk_trim (self->u.chunk, n);
+        self->u.chunk = nn_chunk_trim(self->u.chunk, n);
         return;
     }