Mercurial > mplayer.hg
comparison m_option.c @ 9177:01a713dcaf23
disable free() in string and string_list parsers. yes, it's a hack
(and a little memleak), but i can explain :)
[note it's just a few kB memleak, but it's the price of stability without
full code review/audit - there are hunderds of possible double free()]
the old config parser didn't free() strings/stringlists, but didn't even
allocate them by default. the new one always free(), and it causes
memcorruption/sig11 at cases like this:
char* dvd_device="/dev/dvd";
{"dvd-device", &dvd_device, CONF_TYPE_STRING, 0, 0, 0, NULL},
since string constansts (allocated in .TEXT segment) cannot be free()'d
author | arpi |
---|---|
date | Thu, 30 Jan 2003 21:28:01 +0000 |
parents | d3b750570887 |
children | e9a2af584986 |
comparison
equal
deleted
inserted
replaced
9176:237b7e51521a | 9177:01a713dcaf23 |
---|---|
319 return (val && VAL(val) && strlen(VAL(val)) > 0) ? strdup(VAL(val)) : NULL; | 319 return (val && VAL(val) && strlen(VAL(val)) > 0) ? strdup(VAL(val)) : NULL; |
320 } | 320 } |
321 | 321 |
322 static void copy_str(m_option_t* opt,void* dst, void* src) { | 322 static void copy_str(m_option_t* opt,void* dst, void* src) { |
323 if(dst && src) { | 323 if(dst && src) { |
324 if(VAL(dst)) free(VAL(dst)); | 324 // if(VAL(dst)) free(VAL(dst)); //FIXME!!! |
325 VAL(dst) = VAL(src) ? strdup(VAL(src)) : NULL; | 325 VAL(dst) = VAL(src) ? strdup(VAL(src)) : NULL; |
326 } | 326 } |
327 } | 327 } |
328 | 328 |
329 static void free_str(void* src) { | 329 static void free_str(void* src) { |
330 if(src && VAL(src)){ | 330 if(src && VAL(src)){ |
331 free(VAL(src)); | 331 // free(VAL(src)); //FIXME!!! |
332 VAL(src) = NULL; | 332 VAL(src) = NULL; |
333 } | 333 } |
334 } | 334 } |
335 | 335 |
336 m_option_type_t m_option_type_string = { | 336 m_option_type_t m_option_type_string = { |
363 int i; | 363 int i; |
364 | 364 |
365 if(!dst || !VAL(dst)) return; | 365 if(!dst || !VAL(dst)) return; |
366 d = VAL(dst); | 366 d = VAL(dst); |
367 | 367 |
368 | 368 // FIXME!!! |
369 for(i = 0 ; d[i] != NULL ; i++) | 369 // for(i = 0 ; d[i] != NULL ; i++) |
370 free(d[i]); | 370 // free(d[i]); |
371 free(d); | 371 // free(d); |
372 VAL(dst) = NULL; | 372 VAL(dst) = NULL; |
373 } | 373 } |
374 | 374 |
375 static int str_list_add(char** add, int n,void* dst,int pre) { | 375 static int str_list_add(char** add, int n,void* dst,int pre) { |
376 char** lst = VAL(dst); | 376 char** lst = VAL(dst); |