Initialize libsym early in trace.c to help the compiler.
[platform/upstream/ltrace.git] / read_config_file.c
index 980b89b..ea3ab88 100644 (file)
@@ -541,12 +541,12 @@ unshare_type_info(struct locus *loc, struct arg_type_info **infop, int *ownp)
                return 0;
 
        struct arg_type_info *ninfo = malloc(sizeof(*ninfo));
-       if (ninfo == NULL) {
+       if (ninfo == NULL || type_clone(ninfo, *infop) < 0) {
                report_error(loc->filename, loc->line_no,
                             "malloc: %s", strerror(errno));
+               free(ninfo);
                return -1;
        }
-       *ninfo = **infop;
        *infop = ninfo;
        *ownp = 1;
        return 0;
@@ -678,6 +678,7 @@ build_printf_pack(struct locus *loc, struct param **packp, size_t param_num)
        struct expr_node *node = malloc(sizeof(*node));
        if (node == NULL) {
                free(*packp);
+               *packp = NULL;
                return -1;
        }
 
@@ -695,14 +696,15 @@ try_parse_kwd(char **str, const char *kwd)
 {
        size_t len = strlen(kwd);
        if (strncmp(*str, kwd, len) == 0
-           && !isalnum(CTYPE_CONV((*str)[len]))) {
+           && !isalnum(CTYPE_CONV((*str)[len]))
+           && (*str)[len] != '_') {
                (*str) += len;
                return 0;
        }
        return -1;
 }
 
-/* XXX extra_param and param_num are a kludge to get in
+/* XXX EXTRA_PARAM and PARAM_NUM are a kludge to get in
  * backward-compatible support for "format" parameter type.  The
  * latter is only valid if the former is non-NULL, which is only in
  * top-level context.  */
@@ -1125,12 +1127,19 @@ process_line(struct protolib *plib, struct locus *loc, char *buf)
        struct prototype fun;
        prototype_init(&fun);
 
+       struct param *extra_param = NULL;
        char *proto_name = NULL;
        int own;
        fun.return_info = parse_lens(plib, loc, &str, NULL, 0, &own, NULL);
        if (fun.return_info == NULL) {
        err:
                debug(3, " Skipping line %d", loc->line_no);
+
+               if (extra_param != NULL) {
+                       param_destroy(extra_param);
+                       free(extra_param);
+               }
+
                prototype_destroy(&fun);
                free(proto_name);
                return -1;
@@ -1157,7 +1166,6 @@ process_line(struct protolib *plib, struct locus *loc, char *buf)
        str = tmp + 1;
        debug(3, " name = %s", proto_name);
 
-       struct param *extra_param = NULL;
        int have_stop = 0;
 
        while (1) {
@@ -1235,6 +1243,7 @@ process_line(struct protolib *plib, struct locus *loc, char *buf)
        if (extra_param != NULL) {
                prototype_push_param(&fun, extra_param);
                free(extra_param);
+               extra_param = NULL;
        }
 
        if (protolib_add_prototype(plib, proto_name, 1, &fun) < 0) {