libcomps icon indicating copy to clipboard operation
libcomps copied to clipboard

use strdup instead of manual malloc+memcpy

Open ret2libc opened this issue 5 years ago • 2 comments

In multiple places strings are copied from one place to another, but instead of using strdup or the str* functions, the project seems to prefer malloc+memcpy, which IMHO results in less readable more error-prone code.

Examples of this: https://github.com/rpm-software-management/libcomps/blob/2ed0fe52d1e7c062a5a42968bb7a7680835914b8/libcomps/src/comps_objmradix.c#L46 https://github.com/rpm-software-management/libcomps/blob/2ed0fe52d1e7c062a5a42968bb7a7680835914b8/libcomps/src/comps_doc.c#L263 https://github.com/rpm-software-management/libcomps/blob/2ed0fe52d1e7c062a5a42968bb7a7680835914b8/libcomps/src/comps_elem.c#L890 https://github.com/rpm-software-management/libcomps/blob/2ed0fe52d1e7c062a5a42968bb7a7680835914b8/libcomps/src/comps_elem.c#L891 .. and many others.

ret2libc avatar Jan 21 '19 16:01 ret2libc