diff options
Diffstat (limited to 'libnl_2/handlers.c')
-rw-r--r-- | libnl_2/handlers.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libnl_2/handlers.c b/libnl_2/handlers.c index 48dcab4a8..ec8d51270 100644 --- a/libnl_2/handlers.c +++ b/libnl_2/handlers.c | |||
@@ -39,14 +39,16 @@ fail: | |||
39 | struct nl_cb *nl_cb_clone(struct nl_cb *orig) | 39 | struct nl_cb *nl_cb_clone(struct nl_cb *orig) |
40 | { | 40 | { |
41 | struct nl_cb *new_cb; | 41 | struct nl_cb *new_cb; |
42 | int new_refcnt; | ||
42 | 43 | ||
43 | new_cb = nl_cb_alloc(NL_CB_DEFAULT); | 44 | new_cb = nl_cb_alloc(NL_CB_DEFAULT); |
44 | if (new_cb == NULL) | 45 | if (new_cb == NULL) |
45 | goto fail; | 46 | goto fail; |
46 | 47 | ||
47 | /* Copy original and set refcount to 1 */ | 48 | /* Preserve reference count and copy original */ |
49 | new_refcnt = new_cb->cb_refcnt; | ||
48 | memcpy(new_cb, orig, sizeof(*orig)); | 50 | memcpy(new_cb, orig, sizeof(*orig)); |
49 | new_cb->cb_refcnt = 1; | 51 | new_cb->cb_refcnt = new_refcnt; |
50 | 52 | ||
51 | return new_cb; | 53 | return new_cb; |
52 | fail: | 54 | fail: |
@@ -82,9 +84,9 @@ struct nl_cb *nl_cb_get(struct nl_cb *cb) | |||
82 | 84 | ||
83 | void nl_cb_put(struct nl_cb *cb) | 85 | void nl_cb_put(struct nl_cb *cb) |
84 | { | 86 | { |
85 | if (!cb) | ||
86 | return; | ||
87 | cb->cb_refcnt--; | 87 | cb->cb_refcnt--; |
88 | if (cb->cb_refcnt <= 0) | 88 | if (cb->cb_refcnt <= 0) |
89 | free(cb); | 89 | free(cb); |
90 | |||
90 | } | 91 | } |
92 | |||