Commit cae9915625155285673ea4e109a5acb9296a314d
1 parent
b8c7c979
Exists in
master
and in
3 other branches
Corrigindo "warning" do valgrind
Showing
1 changed file
with
9 additions
and
6 deletions
Show diff stats
util.c
... | ... | @@ -1157,8 +1157,8 @@ LIB3270_EXPORT char * lib3270_get_resource_string(const char *first_element, ... |
1157 | 1157 | |
1158 | 1158 | #else |
1159 | 1159 | |
1160 | - char buffer[4096]; | |
1161 | - char * ptr = buffer; | |
1160 | + char * str = lib3270_malloc(4097); | |
1161 | + char * ptr = str; | |
1162 | 1162 | const char * element; |
1163 | 1163 | va_list args; |
1164 | 1164 | const char * res; |
... | ... | @@ -1167,10 +1167,10 @@ LIB3270_EXPORT char * lib3270_get_resource_string(const char *first_element, ... |
1167 | 1167 | |
1168 | 1168 | for(element = first_element;element;element = va_arg(args, const char *)) |
1169 | 1169 | { |
1170 | - if(ptr != buffer) | |
1170 | + if(ptr != str) | |
1171 | 1171 | *(ptr++) = '.'; |
1172 | 1172 | |
1173 | - strncpy(ptr,element,4096-strlen(buffer)); | |
1173 | + strncpy(ptr,element,4096-strlen(str)); | |
1174 | 1174 | ptr += strlen(ptr); |
1175 | 1175 | } |
1176 | 1176 | |
... | ... | @@ -1178,9 +1178,12 @@ LIB3270_EXPORT char * lib3270_get_resource_string(const char *first_element, ... |
1178 | 1178 | |
1179 | 1179 | *ptr = 0; |
1180 | 1180 | |
1181 | - trace("%s: %s",__FUNCTION__,buffer); | |
1181 | + res = get_resource(str); | |
1182 | + | |
1183 | + trace("%s(%s)=%s",__FUNCTION__,str,res ? res : "NULL"); | |
1184 | + | |
1185 | + lib3270_free(str); | |
1182 | 1186 | |
1183 | - res = get_resource(buffer); | |
1184 | 1187 | if(res) |
1185 | 1188 | return strdup(res); |
1186 | 1189 | #endif | ... | ... |