comparison tools/64vw.c @ 1515:66c75f6982e2

Plug some memory leaks in 64vw.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 11 May 2018 22:49:07 +0300
parents 3b220604ae3c
children 530ce92c513f
comparison
equal deleted inserted replaced
1514:61a5bbaf8d5c 1515:66c75f6982e2
360 goto fail; 360 goto fail;
361 } 361 }
362 362
363 if (fmt == NULL || cimage == NULL) 363 if (fmt == NULL || cimage == NULL)
364 { 364 {
365 dmC64ImageFree(cimage);
365 dmErrorMsg("Probing could not find any matching image format. Perhaps try forcing a format via -f.\n"); 366 dmErrorMsg("Probing could not find any matching image format. Perhaps try forcing a format via -f.\n");
366 goto fail; 367 goto fail;
367 } 368 }
368 369
369 // Create surface (we are lazy and ugly) 370 // Create surface (we are lazy and ugly)
370 if ((surf = SDL_CreateRGBSurface(SDL_SWSURFACE, cimage->width, cimage->height, 8, 0, 0, 0, 0)) == NULL) 371 if ((surf = SDL_CreateRGBSurface(SDL_SWSURFACE, cimage->width, cimage->height, 8, 0, 0, 0, 0)) == NULL)
371 { 372 {
373 dmC64ImageFree(cimage);
372 dmErrorMsg("Could not allocate surface.\n"); 374 dmErrorMsg("Could not allocate surface.\n");
373 goto exit; 375 goto exit;
374 } 376 }
375 377
376 if (dmDecodeC64Image(cimage, fmt, surf) == DMERR_OK) 378 if (dmDecodeC64Image(cimage, fmt, surf) == DMERR_OK)
384 { 386 {
385 fprintf(stdout, "\n%s\n", filename); 387 fprintf(stdout, "\n%s\n", filename);
386 dmC64ImageDump(stdout, cimage, fmt); 388 dmC64ImageDump(stdout, cimage, fmt);
387 } 389 }
388 } 390 }
391
392 dmC64ImageFree(cimage);
389 393
390 fail: 394 fail:
391 if (surf == NULL && (surf = SDL_CreateRGBSurface(SDL_SWSURFACE, 320, 200, 8, 0, 0, 0, 0)) == NULL) 395 if (surf == NULL && (surf = SDL_CreateRGBSurface(SDL_SWSURFACE, 320, 200, 8, 0, 0, 0, 0)) == NULL)
392 { 396 {
393 dmErrorMsg("Could not allocate surface.\n"); 397 dmErrorMsg("Could not allocate surface.\n");