Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Loading multiple assets isn't threadsafe. #4

Open
nemosupremo opened this issue Aug 1, 2013 · 0 comments
Open

Loading multiple assets isn't threadsafe. #4

nemosupremo opened this issue Aug 1, 2013 · 0 comments

Comments

@nemosupremo
Copy link
Owner

Loading two gifs from the asset directory will cause undefined behavior.

Fix:
libgifdrawable.c @ c58e2ec
Line 45:

typedef struct GifAnimInfo {
  int duration;
  int current_frame;
+   int fd;
+   int bytesLeft;
} GifAnimInfo;

- int fd, bytesLeft;

Line 254:

static int readFunc(GifFileType* gif, GifByteType* bytes, int size)
{
+  int szRead = read(((GifAnimInfo *)gif->UserData)->fd, bytes, MIN(size, ((GifAnimInfo *)gif->UserData)->bytesLeft));
+  ((GifAnimInfo *)gif->UserData)->bytesLeft -= szRead;
  return szRead;
}

Line 273:

+GifAnimInfo * gif_info = malloc(sizeof(GifAnimInfo));
+gif_info->fd = fd;
+gif_info-> bytesLeft = bytesLeft;
+GifFileType* gif = DGifOpen((void *)gif_info,&readFunc,&error);
error = DGifSlurp(gif);
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant