Skip to content

Commit

Permalink
WebIDL: Copy char* before use it, closes libass#77
Browse files Browse the repository at this point in the history
  • Loading branch information
TFSThiagoBR98 committed Feb 14, 2022
1 parent 2599a21 commit 0b59858
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion build/webidl_binder.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,12 @@ def render_function(class_name, func_name, sigs, return_type, non_pointer,
get_sigs = {0: []}
set_sigs = {1: [Dummy({'type': m.type})]}
get_call_content = take_addr_if_nonpointer(m) + 'self->' + attr
set_call_content = 'self->' + attr + ' = ' + deref_if_nonpointer(m) + 'arg0'
if m.type.isDOMString():
set_call_content = """ char* copy = (char*)malloc(strlen(%s) + 1);
strcpy(copy, %s);
self->%s = copy""" % (deref_if_nonpointer(m) + 'arg0', deref_if_nonpointer(m) + 'arg0', attr)
else:
set_call_content = 'self->' + attr + ' = ' + deref_if_nonpointer(m) + 'arg0'

get_name = 'get_' + attr
mid_js += [r'''
Expand Down

0 comments on commit 0b59858

Please sign in to comment.