Skip to content

Commit eefd56d

Browse files
committed
Fixed problem in setReferencePrefix().
1 parent b79182f commit eefd56d

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

markdowndoc_class.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ static void free_object_storage(void *object TSRMLS_DC)
132132
mkd_cleanup(dobj->markdoc);
133133
dobj->markdoc = NULL;
134134
}
135+
if (dobj->ref_prefix != NULL) {
136+
efree(dobj->ref_prefix);
137+
dobj->ref_prefix = NULL;
138+
}
135139

136140
markdowndoc_free_callback(&dobj->url_fci, &dobj->url_fcc);
137141
markdowndoc_free_callback(&dobj->attr_fci, &dobj->attr_fcc);
@@ -160,6 +164,7 @@ static zend_object_value ce_create_object(zend_class_entry *class_type TSRMLS_DC
160164
dobj->url_fcc = NULL;
161165
dobj->attr_fci = NULL;
162166
dobj->attr_fcc = NULL;
167+
dobj->ref_prefix = NULL;
163168

164169
zov.handle = zend_objects_store_put(dobj,
165170
(zend_objects_store_dtor_t) zend_objects_destroy_object,

markdowndoc_class.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ typedef struct discount_object {
3737
zend_fcall_info_cache *url_fcc;
3838
zend_fcall_info *attr_fci;
3939
zend_fcall_info_cache *attr_fcc;
40+
char *ref_prefix;
4041
} discount_object;
4142

4243
extern zend_class_entry *markdowndoc_ce;

markdowndoc_meth_misc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,11 @@ PHP_METHOD(markdowndoc, setReferencePrefix)
201201
RETURN_FALSE;
202202
}
203203

204-
mkd_ref_prefix(dobj->markdoc, prefix);
204+
if (dobj->ref_prefix != NULL) {
205+
efree(dobj->ref_prefix);
206+
}
207+
dobj->ref_prefix = estrndup(prefix, prefix_len);
208+
mkd_ref_prefix(dobj->markdoc, dobj->ref_prefix);
205209

206210
RETURN_TRUE;
207211
}

0 commit comments

Comments
 (0)